Skip to content

Instantly share code, notes, and snippets.

@Marwe
Created November 16, 2021 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marwe/25e67c0cd5b4b849f90e40cca8cce68e to your computer and use it in GitHub Desktop.
Save Marwe/25e67c0cd5b4b849f90e40cca8cce68e to your computer and use it in GitHub Desktop.
#!/bin/bash
for i in "$@"
do
dn=$(dirname "$i")
bn=$(basename "$i")
if grep -Eq '^[0-9]{4}-[0-9]{2}-[0-9]{2}_' <<< "$bn"
then
echo "# date existing on $bn ($i)"
continue
fi
dt="$(stat -c %y "$i" | cut -d ' ' -f 1)_"
echo -n '# mv says:'
mv -v -u "$i" "$dn/$dt$bn"
echo "mv \"$dn/$dt$bn\" \"$i\" # to reverse"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment