LinuxQuestions.org
Help answer threads with 0 replies.
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 12-27-2012, 09:26 AM   #1
dc_oops
LQ Newbie
 
Registered: Dec 2012
Posts: 1

Rep: Reputation: Disabled
Run into a bit of a pickle - Tried to rename some files, and they've disappeared!


Hello!

I have run into a bit of a pickle with the following command I ran:

Code:
find /media/<rest of listing>/archive -name '*:*' -exec rename ':' '_' {} +
Essentially, a load of files had a colon in their file name. I wanted to replace this with an underscore so I could open them on a Windows based operating system.

I ran the command above, and they have now disappeared from the file listing. After looking at my external hard drive on Windows and using Recuva (Piriform's software), I was told that it is "unrecoverable" and it seems to have gotten confused as to where the file is placed, listing its location as "H:/?".

My question is simply: How the hell do I get my files back?!
Any help is greatly appreciated. And yes, I know I should have backed it up etc etc, but isn't hindsight a wonderful thing!


Cheers
 
Old 12-27-2012, 10:15 AM   #2
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,665

Rep: Reputation: 487Reputation: 487Reputation: 487Reputation: 487Reputation: 487
Hi, Welcome to LQ!

Use photorec. Install it if not yet in your system.

Hope that helps, good luck.
 
Old 12-27-2012, 01:27 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,973
Blog Entries: 12

Rep: Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038
Have you tried to view if the files are there via?

Code:
ls -a
I'm assuming that /media/<rest of listing>/archive still exists, correct?

I'm saying this because when you perform the
Code:
ls -a
command, you should see files which have names that normally make them hidden for a normal
Code:
ls
command. But if the files and/or directories are still there just with hidden names, you firstly can still traverse into those directories using the exacting names, or merely rename the directories using the
Code:
mv
command. You'll be able to see the files and then know how to deal with them. See my comment at the end by the way for an alternative.

Yes, hindsight is the unfortunate dilemma you're stuck in. For the future, if there's something complicated such as this, which could have sweeping effects, even if you seem sure, it may be more prudent to validate the outcome first, i.e.

Code:
find /media/<rest of listing>/archive -name "*:*"
Verify that this gives you the files desired.

Then next execute your rename command on one of those files only and verify that it works as you expect.

And as they say, you learn something new everyday. Kudos to you because I've always renamed batch files via some other more complicated means using sed or gawk. Didn't even know there was such a shell command as rename. I like it. What I've done at times to rename a bunch of files, is complicated. I use
Code:
ls <file-filter> > t.sh
and what that does is places the outcome of my ls command into t.sh. I then edit t.sh as a CSV file using a spreadsheet program, copy that column to make two of them, insert a first column all as mv, and then re-save it as CSV. The result is each line shows up as
Code:
mv,<filename>,<filename>
and then I edit that and search/replace the second filename in each grouping to be my desired outcome. Yes it seems lengthy, but instead of running a killer command, I'm running the same command in a form that I understand clearly and since I'm good at find-replace and a good typist, it doesn't bother me to do it this way. Still, I shall experiment with the rename command now that I know about it. :-)

Last edited by rtmistler; 12-27-2012 at 01:58 PM. Reason: amplifying reason for ls -a usage
 
Old 12-27-2012, 03:34 PM   #4
codergeek
Member
 
Registered: Dec 2012
Posts: 52

Rep: Reputation: 7
You can use photorec. Here is a demo video of it's usage
http://www.youtube.com/watch?v=X91sKWXqW6w
 
  


Reply


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
[SOLVED] In a bit of a pickle about my extended partition! samsam2 Linux - Newbie 12 10-16-2012 07:34 AM
running 32 bit C code .exe file using more memory to run on 64 bit machine? gajananh999 General 9 08-07-2012 09:16 AM
Application to eliminate doubles in files and rename changed files with date? S. Chapelin Linux - Software 6 01-16-2011 03:02 AM
cannot run any binary files at all FC12 64 bit kmacphail Fedora 11 11-25-2009 05:46 AM
Trouble with making a bash script to read in different files and rename output files. rystke Linux - Software 1 05-07-2009 09:00 AM

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

All times are GMT -5. The time now is 01:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration