Skip to content

Instantly share code, notes, and snippets.

@Psycojoker
Created April 28, 2018 06:12
Show Gist options
  • Select an option

  • Save Psycojoker/27ac0101520f47df9e94c5706c6f4223 to your computer and use it in GitHub Desktop.

Select an option

Save Psycojoker/27ac0101520f47df9e94c5706c6f4223 to your computer and use it in GitHub Desktop.
#!/bin/bash
TARGET=/where/you/want/
find $1 -maxdepth 1 -iname "[^.]*" -mtime +100 -type f | while read -r i
do
if [ -e "${TARGET}${i}" ]
then
new_name=${RANDOM}-$i
echo "$i -> ${TARGET}$new_name"
mv "$i" "${TARGET}$new_name"
else
echo "$i -> ${TARGET}$i"
mv "$i" "${TARGET}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment