Sample Header Ad - 728x90

Finding and removing duplicate files: Integrating a unix script with an application that opens a file for viewing?

0 votes
0 answers
37 views
Does anyone know of an open source application or perhaps how to integrate an existing find dupes script with some OS tool (emacs, vim, Finder.app, mc, etc...) to open a file before marking that file for deletion? And perhaps know of open source Unix based console based tools that manage and delete duplicate files? I'm using MacOS. I'm asking here because it's Unix related and I'm hoping to leverage some dupes scripts if necessary. I created the following script to find duplicate files and create output with #rm duplicate_filen in groups such that a line can be commented out and the script invoked to delete duplicates. I'm wondering if such scripts could be used with other applications. Hoping to ask here before reinventing this. #!/usr/bin/env ksh FINDOUT=$(mktemp) ( find "${@}" -type f -print0 | xargs -0 shasum ) > $FINDOUT HASHES=$(find "${@}" -type f -print0 | xargs -0 shasum | awk '{ print $1; }' | sort | uniq -d) DUPELIST=$(mktemp) DUPES=$(mktemp) for h in $HASHES; do if grep "^$h " $FINDOUT >> $DUPES; then echo "" >> $DUPELIST cat $DUPES >> $DUPELIST fi rm $DUPES done RMSCRIPT=$(mktemp) cat $DUPELIST | cut -d " " -f 2- > $RMSCRIPT echo "#!/usr/bin/env ksh" echo "# Duplicate files, remove comments and invoke script" while read -r l; do if [ "$l" != "" ]; then echo "#rm \"$l\"" else echo $l fi done < $RMSCRIPT rm $FINDOUT $RMSCRIPT $DUPELIST
Asked by atod (155 rep)
Jun 21, 2025, 03:54 AM
Last activity: Jun 21, 2025, 04:49 AM