LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-09-2010, 11:25 AM   #1
kmacphail
Member
 
Registered: Jan 2009
Location: Isle of Lewis
Distribution: Gentoo, Crunchbang (XFCE)
Posts: 133
Blog Entries: 1

Rep: Reputation: 18
Used mv to move folder, but where are the files?


I have recently taken to using the command line more in order to gain more experience and increase my knowledge of the Linux systems.

I have a (pretty major maritally) problem. I moved the folders containing our pictures using the mv command:

Quote:
mv /{original_position} /{new_position}
This appeared to work until I noticed that the folders only have been moved and there is no sign of the files in either the original source or destination.

Where have they gone and can I get them back?

Next time I'm copying them and deleting the source when I make sure they are safe!!!!

Well you learn from mistakes but I really would like these back, if only to avoid deafness and a 20 year headache.
 
Old 01-09-2010, 11:31 AM   #2
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,758

Rep: Reputation: Disabled
#man mv

your command should move source files to destination directory?
 
Old 01-09-2010, 11:35 AM   #3
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 402

Rep: Reputation: 51
If you know a filename of some of the files you lost, you could use find utility:
Code:
find /directory/to/start/search/from -name "your_file_name.ext"
or, for case-insensible search, change -name to -iname. For more info,
Code:
man find
.

Last edited by 10110111; 01-09-2010 at 11:36 AM.
 
Old 01-09-2010, 11:47 AM   #4
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,758

Rep: Reputation: Disabled
or try
#locate part-of-filename
 
Old 01-09-2010, 12:31 PM   #5
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 402

Rep: Reputation: 51
Quote:
#locate part-of-filename
Should have done updatedb for this to work... so find might be more efficient for one-time search.
 
Old 01-09-2010, 02:05 PM   #6
highfructose327
Member
 
Registered: Mar 2008
Location: Ohio, USA
Distribution: Mint, Fedora
Posts: 64

Rep: Reputation: 21
Wow that is odd, maybe try testdisk/photorec to recover the images. I have used it to recover images that were deleted, it worked well. http://www.cgsecurity.org/wiki/PhotoRec to install in fedora
Code:
yum install testdisk
Goodluck
 
Old 01-09-2010, 03:23 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
This aspect of a Linux (or any) filesystem should be pretty much deterministic.

Within one physical drive, a mv command will not actually relocate anything---it only changes the info used to get to the folder/files. As others have pointed out, the files will be recoverable. (Just don't write to the disk.)

I am curious about your description of the move: "mv /source /destination". You would not normally be moving files or folders at the root level like that. Can you post exactly where the folder was and exactly what command you used?
 
Old 01-09-2010, 09:51 PM   #8
titetanium
Member
 
Registered: Mar 2004
Distribution: debian testing/unstable
Posts: 68

Rep: Reputation: 16
A safer option would have been to run
Quote:
cp -a /source /destination
and then compare them to make sure they are the same before deleting the /source directory. Even better:
Quote:
tar -jvcf backup.tar.bz2 /source && cp -a backup.tar.bz2 /destination/ && cd /destination && bzip2 -dc backup.tar.bz2 |tar xvf -
That's just an example of what can be done.
 
Old 01-09-2010, 11:09 PM   #9
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
I suggest also using the -v option to provide verbose output, both for mv and cp. Set it up as an alias for it so that it becomes the default behavior. It would've probably told you instantly what happened.

You might also consider the -i option, which makes it ask you interactively before actually performing the move, although that can become tedious when you're operating on a large number of files at once. One compromise is to use -i for the first few files, then crtl+c terminate the command and re-run it for the rest of them without the interaction.
 
Old 01-10-2010, 06:21 PM   #10
kmacphail
Member
 
Registered: Jan 2009
Location: Isle of Lewis
Distribution: Gentoo, Crunchbang (XFCE)
Posts: 133
Blog Entries: 1

Original Poster
Rep: Reputation: 18
Well folks, thanks to everybody for the help and advice. I searched using parts of the file names, extensions but got nothing. However I did try photorec after a suggestion from highfructose327 and that has recovered my files. I will definitely copy my files from now on rather than moving them. Again thanks to everybody for their advice.
 
Old 01-10-2010, 06:28 PM   #11
kmacphail
Member
 
Registered: Jan 2009
Location: Isle of Lewis
Distribution: Gentoo, Crunchbang (XFCE)
Posts: 133
Blog Entries: 1

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by pixellany View Post
I am curious about your description of the move: "mv /source /destination". You would not normally be moving files or folders at the root level like that. Can you post exactly where the folder was and exactly what command you used?
I used the command as follows:

mv /home/kevie/pics /temp/

I was keeping the stuff I was wanting before cleaning out my home folder, I had previously made a folder called temp with the mkdir command. Like I said I am trying to use the command line more and have been consulting the Command Line and Shell Scripting Bible.
 
Old 01-11-2010, 02:09 AM   #12
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
There's no need to be afraid to use mv or to be overly-cautious with it. But you do have to watch what you're doing. I think the problem you had is mostly because the default action for many *nix tools is to work silently, without feedback. You just need to set things up to provide you with some interaction, gain some experience, and you'll be fine.

There's a package I recommend called removeutils. Two of the programs it contains are imv and icp, which work just like the standard mv and cp, but if you give them only a single file or directory argument it will place it in an edit buffer and let you simply rename it directly. I've found it very convenient and safer than the originals when renaming files and moving directory trees. You can set up aliases so that they can perform as substitutes for the core versions.

I still suggest using the interactive options, of course.
 
Old 01-11-2010, 02:15 AM   #13
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Debian, SL
Posts: 5,314

Rep: Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141
Quote:
Originally Posted by kmacphail View Post
I used the command as follows:

mv /home/kevie/pics /temp/
Just to check, whas it really "/temp/" or was it "/tmp/". If the latter did you reboot your machine? On many systems all files in /tmp/ will be deleted on a reboot.

Evo2.
 
Old 01-11-2010, 06:06 AM   #14
kmacphail
Member
 
Registered: Jan 2009
Location: Isle of Lewis
Distribution: Gentoo, Crunchbang (XFCE)
Posts: 133
Blog Entries: 1

Original Poster
Rep: Reputation: 18
Evo2

I did make sure that I made the folder called "temp", I may not be that experienced but I am aware that if I moved files I needed to "tmp" that I would not see them in a hurry, that's why I used the "temp" folder as it was not native and does stick out a bit at root level.

David the H

Thanks I will look into that package.
 
  


Reply

Tags
command, files, line, mv


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to tell bash to move files to another folder? hq4ever Linux - Newbie 10 12-30-2010 03:15 AM
[SOLVED] Bash script needed to move files to another folder. No_one_knows_me Linux - General 28 01-07-2010 10:29 PM
Move files into a folder created by Perl ifeatu Programming 4 12-12-2009 09:41 PM
How to automatically move files from one folder into another folder? xmrkite Linux - Software 6 11-05-2006 10:39 AM
How to move a folder and replace files RAdams Linux - Newbie 2 06-24-2006 12:11 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration