LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   move directory and contents (https://www.linuxquestions.org/questions/linux-general-1/move-directory-and-contents-917088/)

porphyry5 12-04-2011 12:25 PM

move directory and contents
 
Is there a single linux command that will move a directory and its contents to a different physical location, i.e. into another directory?

acid_kewpie 12-04-2011 12:43 PM

yes, just "mv directory new_directory". nothing fancy at all.

Doc CPU 12-04-2011 12:45 PM

Hi there,

Quote:

Originally Posted by porphyry5 (Post 4541794)
Is there a single linux command that will move a directory and its contents to a different physical location, i.e. into another directory?

yes, of course - probably mv is what you're looking for.
The mv command doesn't care whether the object you wish to move/rename is a single file or a directory.

[X] Doc CPU

porphyry5 12-04-2011 01:12 PM

Quote:

Originally Posted by acid_kewpie (Post 4541804)
yes, just "mv directory new_directory". nothing fancy at all.

Quote:

Originally Posted by Doc CPU (Post 4541807)
Hi there,
yes, of course - probably mv is what you're looking for.
The mv command doesn't care whether the object you wish to move/rename is a single file or a directory.
[X] Doc CPU

That's what I tried, and it did this
Code:

~/Films/The Tragedy of Macbeth (1971) DVD9 $mv . /media/500gb/Films
mv: inter-device move failed: `.' to `/media/500gb/Films/.'; unable to remove target: Is a directory
~/Films/The Tragedy of Macbeth (1971) DVD9 $mv '.' /media/500gb/Films/
mv: inter-device move failed: `.' to `/media/500gb/Films/.'; unable to remove target: Is a directory
~/Films/The Tragedy of Macbeth (1971) DVD9 $mv "." /media/500gb/Films/
mv: inter-device move failed: `.' to `/media/500gb/Films/.'; unable to remove target: Is a directory


acid_kewpie 12-04-2011 01:13 PM

you can't move the directory you are in, as calling it "." means that the destination will be "." in the destination directory, which IS the directory itself, which makes no sense.

porphyry5 12-04-2011 01:22 PM

Quote:

Originally Posted by acid_kewpie (Post 4541829)
you can't move the directory you are in, as calling it "." means that the destination will be "." in the destination directory, which IS the directory itself, which makes no sense.

Thanks, got it now. It has to be like so, from a different directory
Code:

mv "/home/g/Films/The Tragedy of Macbeth (1971) DVD9" /media/500gb/Films/


All times are GMT -5. The time now is 12:05 AM.