The move command with wildcards

Discussion in 'Mac OS X Server, Xserve, and Networking' started by Silas1066, Oct 8, 2010.

  1. Silas1066 macrumors regular

    Joined:
    Nov 1, 2009
    #1
    How do I specify all the documents within a directory when using the mv (move) command?

    In other words, if I wanted to copy the contents of one folder into another from the command line, how do I do it?
     
  2. willieva macrumors 6502

    Joined:
    Mar 12, 2010
    #2
    If you want to move everything from here to ../there:
    mv * ../there
     
  3. aarond12 macrumors 65816

    aarond12

    Joined:
    May 20, 2002
    Location:
    Dallas, TX USA
    #3
    In the first sentence, you mentioned "move". In the second, you mentioned "copy". Here is both:

    mv *.doc directoryname
    cp *.doc directoryname

    -Aaron-
     
  4. Silas1066 thread starter macrumors regular

    Joined:
    Nov 1, 2009
    #4
    Still not taking it.

    Let's say I have 2 folders in my Documents folder

    /Documents/dissertation

    and

    /Documents/backups

    I want to move all the .doc files from the first into the second. What would be the command?
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    Code:
    mv /Documents/dissertation/*.doc /Documents/backups
    Note that this won't retain directory structure if there are folders inside dissertation (I believe). Also, as you gave it, Documents is a folder at the root level on the machine, which likely isn't the case.
     
  6. Silas1066 thread starter macrumors regular

    Joined:
    Nov 1, 2009
    #6
    it will work if I go into a folder, create a new one in there, and copy stuff to it (*.pdf for instance)

    but I guess I cam going to have to specify the full path from the root if I want to do it any other way (do a pwd first I guess)

    actually, I can't get it to work even when specifying the full path from the root

    something wrong with the syntax here
     
  7. ytk macrumors regular

    Joined:
    Jul 8, 2010
    #7
    You may not be specifying your path correctly. It's unlikely you have a /Documents folder, as this would refer to a folder at the root of your boot drive. Much more likely is ~/Documents, since ~ is a shortcut to refer to your home directory. However, the best way to make sure your path is specified correctly is to start typing the name of the path, then hit Tab to autocomplete the directory name. For example, start typing ~/Doc and then hit Tab, and it should automatically complete to ~/Documents/ . If it adds the trailing / then you know that it's referring to a directory. If it just beeps at you and does nothing, try hitting Tab again. If there are multiple options for completion, hitting Tab will list them. If there are no matches, it will just beep at you again.

    Try the following keystroke sequence and see if you can get it to work:

    Code:
    cp ~/Docu<TAB>disser<TAB>*.doc ~/Doc<TAB>backu<TAB>
     

Share This Page