Skip to content

Instantly share code, notes, and snippets.

@dazzag24
Created May 12, 2020 20:48
Show Gist options
  • Save dazzag24/a8974e46ba16b525aca2014de84487e8 to your computer and use it in GitHub Desktop.
Save dazzag24/a8974e46ba16b525aca2014de84487e8 to your computer and use it in GitHub Desktop.
Rename files based on creation date of file
convert () {
local f=$1
echo "Processing ${f}"
local filedate=$( stat -c '%y' ${f} | awk -F"." '{print $1}' | awk -F" " '{printf "%s %s", $1, $2}' | sed 's/:/./g' - )
echo "${filedate}-${f}"
cp ${f} "../101MEDIA/${filedate}-${f}"
}
for f in $(ls); do convert $f; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment