Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 19 lines (17 sloc) 346 Bytes
#!/bin/bash
lastfile=""
if [[ ! $* ]]; then
echo "usage: $0 <directory>"
exit 1
fi
if [[ ! -e "$1/old/" ]]; then
mkdir "$1/old/"
fi
for file in $(ls -r $1); do
stripped=${file%%-[0-9].*}
if [[ "$stripped" == "$lastfile" ]]; then
echo "moved duplicate $1/$file"
mv "$1/$file" "$1/old/"
fi
lastfile=$stripped
done
Something went wrong with that request. Please try again.