dotfiles/.local/bin/scripts/predate

9 lines
309 B
Bash
Executable File

#!/bin/sh -e
# Add the modification date in front of the filename
IFS='\n'
for file
do mv --verbose --interactive "$file" \
"$(latest "$file" | head -2 | tail -1 | cut -d'+' -f1)_$(echo "$file" | sed 's/20\([0-9]\{2\}\)-\([0-9]\{2\}\)\(-[0-9]\{2\}\)\?_\?//')"
done
# stat --format %y "$file" | cut -d' ' -f1