LoginSignup
1
0

More than 5 years have passed since last update.

ファイルをかき集めてくる。ただし重複ファイルは1つのみ集める。

Last updated at Posted at 2012-08-12

$1にあるファイルを$2にハードリンクする。内容が同じファイルは、それらのうちどれか1つだけがリンクされる。

mufufu.sh
#!/bin/sh
if [ $# -ne 2 ]; then
    echo "usage: `basename $0` search_dir copy_dir" >&2
    exit 1
fi
if [ ! -e "$2" ]; then
    mkdir "$2" || exit 1
fi
if [ ! -d "$2" ]; then
    exit 1
fi

find "$1" -wholename "$2" -prune -o -type f -regex '.*\(jpg\|png\)' -print0 | xargs -0 md5sum | sort -k 1,1 | uniq -w 32 | while read md5 fname ; do ln -f "$fname" "$2"/"${md5}_`basename "$fname"`" ; done
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0