Find the answer to your Linux question:
Results 1 to 6 of 6
Hello there, installed Ubuntu 12.04 to teach myself Linux. thought I was doing well learning Terminal commands until!!!! made directory on Desktop called images put jpg on Desktop called What ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2013
    Location
    Bristol UK
    Posts
    3

    mv command changes filename


    Hello there, installed Ubuntu 12.04 to teach myself Linux. thought I was doing well learning Terminal commands until!!!!
    made directory on Desktop called images
    put jpg on Desktop called What A Choice.jpg
    used mv What A Choice.jpg images (to move jpg to images directory)
    had errors re ''cannot stat'' as jpg name was seen as 3 pieces, What A and Choice.
    So renamed jpg to WhatAChoice.jpg ie no spaces and
    mv WhatAChoice.jpg images moved the jpg to the images folder.

    To move jpg back to the Desktop I used
    mv WhatAchoice.jpg Desktop and this renamed my jpg to Desktop.

    So 2 questions, how do I use/mv/save jpegs without having to save filenames without spaces and why does my mv WhatAChoice.jpg Desktop rename the file instead of moving it.

    All help appreciated, really enjoying using the Terminal.

  2. #2
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,110
    Don't create files with spaces. If you do have files with spaces, you need quotes os it isn't seen the way you mention. If you have a file named What A Choice.jpg and you want to move it to your /home/username/images directory you would do this:

    Code:
    mv "What A Choice.jpg" /home/username/images/
    mv WhatAchoice.jpg Desktop and this renamed my jpg to Desktop.
    Yep, expected behavior. You did it wrong. You are basically renaming that file. If you want to move WhatAchoice.jpg to the Desktop directory, you would need to preface it with a forward slash and have a forward slash at the end.

    Code:
    mv WhatAchoice.jpg /home/username/Desktop/
    Last edited by jayd512; 08-10-2013 at 07:52 PM. Reason: fixed [QUOTE] tag

  3. #3
    Just Joined!
    Join Date
    Aug 2013
    Location
    Bristol UK
    Posts
    3
    Much appreciated, this is info that's difficult to find in my pile of books.
    Thanks again
    Last edited by cazador; 08-10-2013 at 06:55 PM. Reason: better grammar

  4. #4
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,110
    This is pretty basic stuff and there are man files on your computer. If you want info on the use of a command, for examplet the mv command just type in a terminal

    man mv

    Some of this stuff is a bit cryptic but, lots of info.

  5. #5
    Just Joined!
    Join Date
    Aug 2013
    Location
    Bristol UK
    Posts
    3
    I wasn't aware of the ''man'' cmd, whilst the switch options are explained in my books that option is well laid out and much easier to follow on screen, will definately be making use of man.
    Thanks again for the prompt response

  6. #6
    Just Joined!
    Join Date
    Aug 2013
    Posts
    7
    I've never really used quotes with file names with spaces. I always just escape the space with a backslash. I believe I started doing it that way because somebody had an issue trying to scp a file with spaces in it and quotes wouldn't allow the file to be copied but I don't remember exactly. And yes, with linux you will need either an absolute path or a relative path. The only way it would recognize Desktop as a folder is if the Desktop folder was in your current working directory.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •