Skip to content

Instantly share code, notes, and snippets.

@netmarkjp
Last active December 23, 2015 03:49
Show Gist options
  • Save netmarkjp/6576285 to your computer and use it in GitHub Desktop.
Save netmarkjp/6576285 to your computer and use it in GitHub Desktop.
1. detect duplicate file(raw and jpg)2. move raw to raw/ dir
rm -f /tmp/all_pics.txt /tmp/dup_pics.txt /tmp/cmds.txt
find /Volumes/BBFS1/toshi-photo -type f -maxdepth 2 | sed -E "s/(.*)\..*/\1/" | sort | uniq -c | grep -v "^ \+1" | sed "s@.*.*[0-9] /@/@" > /tmp/dup_pics.txt
iconv -f utf8 -t utf8-mac /tmp/dup_pics.txt | while read line; do ls $line.* >> /tmp/all_pics.txt ; done
grep -iE "\.(pef|arw|cr2)$" /tmp/all_pics.txt | sed -E "s@(.*)/(.*)@mv \1/\2 \1/raw/\2@" > /tmp/cmds.txt
iconv -f utf8 -t utf8-mac /tmp/dup_pics.txt | sed -E "s@(.*/).*@\1@" | uniq | while read line; do mkdir ${line}raw ;done
bash /tmp/cmds.txt
rsync -av --exclude 'raw' /Volumes/BBFS1/toshi-photo/ /Users/baba/Pictures/original/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment