Moving files in Terminal

Discussion in 'macOS' started by adn rcd dly, Apr 12, 2010.

  1. adn rcd dly macrumors 6502

    adn rcd dly

    Joined:
    Nov 23, 2004
    Location:
    Salt Lake City, UT
    #1
    Hey guys,

    I am just learning Terminal and so far it has been fun but frustrating. I'm learning from online manuals and the manual within Terminal so everything is pretty verbose for someone that doesn't know the language yet. I apologize if this has been answered elsewhere, but the search gave me many results about moving files to the Trash or making a folder hidden. These are not my concerns for today. And for the reference, I know this can be done as a "drag-and-drop" operation in Finder, but as I said, I'm learning :p

    So I am trying to move a couple of PDFs from my Documents folder to one I created within the Documents folder.

    The command I have been trying is
    Code:
    mv /Users/adn/Documents/"UT State TX Receipt.pdf" ~/Users/adn/Documents/Finances
    Using that code I got "Permission denied"
    So I tried
    Code:
    sudo mv /Users/adn/Documents/"UT State TX Receipt.pdf" ~/Users/adn/Documents/Finances
    Prompted for the password, I entered it and got: "No such file or directory"

    Any help would be greatly appreciated.

    Using Terminal 2.0.2 on a Mac Mini using OS X 10.5.8

    Thanks again guys.
     
  2. gr8tfly macrumors 603

    gr8tfly

    Joined:
    Oct 29, 2006
    Location:
    ~119W 34N
    #2
    The quotes need to be around the entire path string, or not used at all (spaces are "\ ").
     
  3. adn rcd dly thread starter macrumors 6502

    adn rcd dly

    Joined:
    Nov 23, 2004
    Location:
    Salt Lake City, UT
    #3
    Code:
    mv /Users/adn/Documents/UT\ State\ TX\ Receipt.pdf ~/Users/adn/Documents/Finances
    so like that? that also gives me "No such file or directory"

    does it make a difference what Directory you are currently in?
     
  4. gr8tfly macrumors 603

    gr8tfly

    Joined:
    Oct 29, 2006
    Location:
    ~119W 34N
    #4
    "~" points to your user home directory (/Users/<username>), so the destination path you are trying to use evaluates to "/Users/adn/Users/adn/......".
     
  5. adn rcd dly thread starter macrumors 6502

    adn rcd dly

    Joined:
    Nov 23, 2004
    Location:
    Salt Lake City, UT
    #5
    Wow. I can't believe I didn't fully read the error it gave.
    "/Users/adn/Users/adn/Documents/Finances: No such file or directory"

    thanks for that info.

    so it continued to give that error but the file is moved. i am looking through all the lines of command and there isn't one line that doesn't have the "No such file or directory" error but it moved anyway. I will try with another file.

    Code:
    mv ~/Documents/File\ Name.pdf ~/Documents/Finances
    does that look correct?
     
  6. gr8tfly macrumors 603

    gr8tfly

    Joined:
    Oct 29, 2006
    Location:
    ~119W 34N
    #6
    Looks right.

    btw: you can drag items from the Finder to Terminal and it will automatically create the correct path string for you for the item.
     
  7. adn rcd dly thread starter macrumors 6502

    adn rcd dly

    Joined:
    Nov 23, 2004
    Location:
    Salt Lake City, UT
    #7
    sweet. it worked out. thanks again for the help. there were about 3 more PDFs so I used
    Code:
     mv ~/Documents/*.pdf ~/Documents/Finances
    worked magnificently. i may go to the Library (the physical one) and look for "Terminal for Dummies"
    :p
     

Share This Page