Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-27-2012, 08:26 AM   #1
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!


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

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!

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

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

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

Hope that helps, good luck.
Old 12-27-2012, 12:27 PM   #3
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,889
Blog Entries: 13

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

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

I'm saying this because when you perform the
ls -a
command, you should see files which have names that normally make them hidden for a normal
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
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.

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
ls <file-filter> >
and what that does is places the outcome of my ls command into I then edit 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
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 12:58 PM. Reason: amplifying reason for ls -a usage
Old 12-27-2012, 02:34 PM   #4
Registered: Dec 2012
Posts: 52

Rep: Reputation: 7
You can use photorec. Here is a demo video of it's usage


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

All times are GMT -5. The time now is 10:41 PM.

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