LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-04-2011, 12:25 PM   #1
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Rep: Reputation: 24
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?
 
Old 12-04-2011, 12:43 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
yes, just "mv directory new_directory". nothing fancy at all.
 
Old 12-04-2011, 12:45 PM   #3
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by porphyry5 View Post
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
 
Old 12-04-2011, 01:12 PM   #4
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by acid_kewpie View Post
yes, just "mv directory new_directory". nothing fancy at all.
Quote:
Originally Posted by Doc CPU View Post
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

Last edited by porphyry5; 12-04-2011 at 01:16 PM.
 
Old 12-04-2011, 01:13 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.

Last edited by acid_kewpie; 12-04-2011 at 01:14 PM.
 
1 members found this post helpful.
Old 12-04-2011, 01:22 PM   #6
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by acid_kewpie View Post
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/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
move partition with directory & contents to another drive. EDDY1 Linux - Newbie 6 08-29-2011 02:40 AM
Using mv to move the contents of one directory into another apachedude Linux - Software 13 01-16-2009 08:57 AM
list contents of directory without listing contents baddah Linux - Newbie 2 06-12-2006 04:02 AM
Move contents of one disk to another and back again spinner_0 Slackware 4 01-20-2006 11:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration