LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-19-2008, 12:57 PM   #1
bashyow
Member
 
Registered: Jun 2008
Location: uk
Distribution: Slackware 12.1, AND IM LOVIN EVERY MINUTE OF IT, JERRY! :D
Posts: 122

Rep: Reputation: 15
replacing folder with mv command


yow,

when i try to move the pictures folder from my camera to my home dir, i use this command

Code:
mv -f /mnt/camera/picfolder ~/
i get this error

Quote:
inter-device move failed, unable to remove target: Is a directory
now, you may have guessed that a folder of the same name already exists in the home dir, and this is part of the problem, but im wondering why the above commandline does not work and simply overwrite the old folder and its pix with the new folder/pix?

Last edited by bashyow; 06-19-2008 at 12:58 PM.
 
Old 06-19-2008, 01:04 PM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
typically a -r or -R are used for recursive. try one of those to move the directory. or just cp -r
 
Old 06-19-2008, 01:11 PM   #3
bashyow
Member
 
Registered: Jun 2008
Location: uk
Distribution: Slackware 12.1, AND IM LOVIN EVERY MINUTE OF IT, JERRY! :D
Posts: 122

Original Poster
Rep: Reputation: 15
-r -R

seem to be invalid options for the mv command.
 
Old 06-19-2008, 01:30 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can try to copy the content of the source directory into the destination directory, then - if succeed - remove the original, for example:
Code:
cp -R /mnt/camera/picfolder/* ~/picfolder
but it is not clear which subfolder already exists in the home directory, so review the command line above to achieve your result.
 
Old 06-19-2008, 02:55 PM   #5
bashyow
Member
 
Registered: Jun 2008
Location: uk
Distribution: Slackware 12.1, AND IM LOVIN EVERY MINUTE OF IT, JERRY! :D
Posts: 122

Original Poster
Rep: Reputation: 15
thankyou lleb and colucix.

i did have to use some 'cp' and 'rm' commands in the script instead of the 'mv' command, but its not a big deal, i just wonder why the move command doesnt do all that for me.

ah well, i did achieve what i wanted, so i guess thats the main thing.
 
Old 06-19-2008, 03:19 PM   #6
ischi
Member
 
Registered: Apr 2008
Location: Tübingen
Distribution: Fedora 9 (Thinkpad T60), Debian 3.1 (Server)
Posts: 51

Rep: Reputation: 15
The problem here is that the move is across 2 devices, the way mv works (and also way -r Options are not used and/or needed) is by replacing the node in the inode table (first sectors of your drive) which points to the folder by the new one, so actually as long as you stay on the same device no data is actually copied, but only the pointer to it is moved. I'm not going to go in more detail now... If you want to know more check out books about OS/Unix.
Now if you try to move a folder across 2 devices this cant obviously be done but Data has to be moved. So mv has to fall back on actually copying data from one device to another and removing it afterwards, and it cant remove the inode to which to copy because if it would remove it theres nothing to copy to, and if it doesnt remove it it cant copy to it because there is still data there (in short and dirty said ). So thats why you cant mv and hav to copy.

For more info I would check Andrew S. Tannenbaum - Modern Operating Systems

Hope I could clear up your confusion a little
 
Old 06-19-2008, 04:58 PM   #7
bashyow
Member
 
Registered: Jun 2008
Location: uk
Distribution: Slackware 12.1, AND IM LOVIN EVERY MINUTE OF IT, JERRY! :D
Posts: 122

Original Poster
Rep: Reputation: 15
i always suspected the concept of the pointer moving, and not the actual file, because when you move a big file to another part of the file system, its almost instant and theres no sound from the HD. i find that pretty cool

thankyou for your more indepth explaination ischi

Last edited by bashyow; 06-19-2008 at 05:00 PM.
 
Old 11-30-2010, 09:29 PM   #8
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by colucix View Post
You can try to copy the content of the source directory into the destination directory, then - if succeed - remove the original, for example:
Code:
cp -R /mnt/camera/picfolder/* ~/picfolder
but it is not clear which subfolder already exists in the home directory, so review the command line above to achieve your result.
I have read that -b could be use also into mv -b -f -v command ... right?
 
Old 09-06-2012, 04:26 AM   #9
aliqasemi
LQ Newbie
 
Registered: Sep 2012
Posts: 7

Rep: Reputation: Disabled
Quote:
Originally Posted by ischi View Post
The problem here is that the move is across 2 devices, the way mv works (and also way -r Options are not used and/or needed) is by replacing the node in the inode table (first sectors of your drive) which points to the folder by the new one, so actually as long as you stay on the same device no data is actually copied, but only the pointer to it is moved. I'm not going to go in more detail now... If you want to know more check out books about OS/Unix.
Now if you try to move a folder across 2 devices this cant obviously be done but Data has to be moved. So mv has to fall back on actually copying data from one device to another and removing it afterwards, and it cant remove the inode to which to copy because if it would remove it theres nothing to copy to, and if it doesnt remove it it cant copy to it because there is still data there (in short and dirty said ). So thats why you cant mv and hav to copy.

For more info I would check Andrew S. Tannenbaum - Modern Operating Systems

Hope I could clear up your confusion a little
This make sence, but I still don't understand why it doesn't leave the destination folder intact and continue on moving the sub-folders/files, like when we copy using nautilus using the "merge" option. I guess it has been someting too modern to implement!

Last edited by aliqasemi; 09-06-2012 at 04:28 AM.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need folder search command..... chillyroll Linux - Software 2 12-01-2006 06:03 AM
folder copy command bobb_roof Linux - Newbie 4 11-04-2006 04:59 PM
replacing a file in a zip from command line davee Linux - General 3 02-28-2006 01:06 PM
dos2unix command on a folder raghunandan Linux - Software 1 12-12-2005 07:50 AM
a command/script for replacing a word with another jaakkop Programming 14 12-04-2005 10:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:50 PM.

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