Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Silas1066

macrumors regular
Original poster
Nov 1, 2009
110
0
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?
 

aarond12

macrumors 65816
May 20, 2002
1,148
108
Dallas, TX USA
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?
In the first sentence, you mentioned "move". In the second, you mentioned "copy". Here is both:

mv *.doc directoryname
cp *.doc directoryname

-Aaron-
 

Silas1066

macrumors regular
Original poster
Nov 1, 2009
110
0
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?
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
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.
 

Silas1066

macrumors regular
Original poster
Nov 1, 2009
110
0
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
 

ytk

macrumors 6502
Jul 8, 2010
252
5
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

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>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.