1

I accidentaly ran a find and mv command as per below to move some files with specific extensions to a directory. Unfortunately it was early and I was tired and I didn't put and slash on the end and all the .ext files are gone and I am left with a file called 'file' with no extension.

   find /folder -iname "*.zip" -exec mv {} /home/zip \;

Question is : How can I reverse or extract my .zip files from this 'file'

I have tried to open with archiver, cat, tail, head and it's just abinary output and archiver can't extract

Note: I am on a Imac

6
  • 1
    That command wouldn't do anything but complain about syntax errors. No terminator on the exec, no operator for the "*.zip". Well actually it would see "*.zip" as a directory to search. But that probably didn't exist. Commented Jul 31, 2012 at 2:32
  • @thor Ah.. What would be a better option? Using cp, then confirming the files and then rm? Or is there better syntax for cp to use? Its mainly for housekeeping. Commented Jul 31, 2012 at 2:35
  • 1
    I can't even figure out what you trying to do, that command is so bizarre. Commented Jul 31, 2012 at 2:36
  • @Rhys: If you're executing potentially destructive commands, prepend them with an echo first and review what will happen. Commented Jul 31, 2012 at 2:37
  • @AlanCurrym I have corrected now. Commented Jul 31, 2012 at 2:40

2 Answers 2

1

You basically did this with your find:

mv a.zip /home/zip
mv b.zip /home/zip
mv c.zip /home/zip

And /home/zip wasn't a pre-existing directory. So those are just regular file renames. Each one overwriting the previous. All files except the last are dead. rm'ed, effectively.

You should be able to rename /home/zip to something more reasonable like foo.zip and unzip it to get the last zip file's contents back. The others are going to require more work.

You may also be interested in this Superuser question about undelete

Sign up to request clarification or add additional context in comments.

1 Comment

What would be the best way to do this?
1

Your command:

find /folder -iname "*.zip" -exec mv {} /home/zip \;

and if /home/zip is NOT a directory, all your zip are gone :( except the last one

Try to quickly unmount your disk, and use external tool like sleuthkit (testdisk) to recover mv-ed files

2 Comments

How to force directory creation to avoid this?
trailing slash on /home/zip/ would have done it. Using the -t form of mv would have done it. mv -i would have at least asked before overwriting anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.