Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

So I recovered all the files that were still available on a corrupted external drive using testdisk. Now I want to sort out the different file extensions and copy them to their respective newly created main directories (.jpg / .doc / .xls etc...)

After some looking around I found that the following entry in the commandline should do the trick, however I get a message stating there is a missing argument for -exec, meaning I am actually stuck. Any input?

find /media/DRIVE-N-GO/Backup\ Wiebe/ -type f -name *.jpg -exec cp {} /media/Elements/jpgs/ \
share|improve this question
    
+1 for actually having researched the problem. –  don.joey Mar 14 at 13:09

2 Answers 2

up vote 4 down vote accepted
find /media/DRIVE-N-GO/Backup\ Wiebe/ -type f -name "*.jpg" -exec cp "{}" /media/Elements/jpgs/ \;

You were missing a ;. The quotes are around the search term for preventing bash from expanding the asterisk The quotes around the parameter of cp are when some files with spaces in the name are hit - because then cp would fail

share|improve this answer
    
Hahahahaha..... just wow. Makes me feel like a complete idiot. Thanks so much people! –  Ruben Mar 14 at 13:03
2  
Also missing quotes around *.jpg. It works fine without escaping the * ... until run it while standing in a directory that happens to have files ending in .jpg. –  geirha Mar 14 at 13:13
1  
@Jacob If this answered your question, you may mark this answer as accepted, by clicking the green check mark next to it. That will indicate that your problem is solved. –  Radu Rădeanu Mar 14 at 13:32

You have to finish the command with an escaped semicolon:

... -exec cp {} directory \;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.