LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Script to move duplicate files (http://www.linuxquestions.org/questions/linux-general-1/script-to-move-duplicate-files-4175457233/)

davholla 04-07-2013 10:05 AM

Script to move duplicate files
 
Due to reasons too boring and embarrassing to relate I have lots of duplicate files. I found this script on line
Code:

find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate| cut -f3-100 -d ' ' | tr '\n.' '\t.' | sed 's/\t\t/\n/g' | cut -f2-100 | tr '\t' '\n' | perl -i -pe 's/([ (){}-])/\\$1/g' | perl -i -pe 's/'\''/\\'\''/g' | xargs -pr rm -v
rm -v ./test2.txt ?...y

However my natural caution means that I want to copy them t

I tried
Code:

find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate| cut -f3-100 -d ' ' | tr '\n.' '\t.' | sed 's/\t\t/\n/g' | cut -f2-100 | tr '\t' '\n' | perl -i -pe 's/([ (){}-])/\\$1/g' | perl -i -pe 's/'\''/\\'\''/g' | xargs -pr rm -v
rm -v ./test2.txt ?...y

but I got

Code:

mv: cannot overwrite non-directory `./test2.txt' with directory `duplicates/'


---------- Post added 04-07-13 at 04:05 PM ----------

Solved it I needed to put the full path to the duplicate directory!!!

pan64 04-08-2013 03:44 AM

this is an extremely inefficient solution, there are tools to do it, for example: http://www.junauza.com/2010/01/how-t...duplicate.html


All times are GMT -5. The time now is 07:27 AM.