dotfiles/.local/bin/scripts/predate

10 lines
396 B
Plaintext
Raw Normal View History

2021-11-25 12:20:13 +00:00
#!/bin/sh -e
# Add the modification date in front of the filename
2021-11-25 12:20:13 +00:00
IFS='\n'
2022-01-11 12:23:56 +00:00
test "$1" = -s && short=true && shift
for file
2021-11-25 12:20:13 +00:00
do mv --verbose --interactive "$file" \
2022-01-11 12:23:56 +00:00
"$(latest "$file" | head -2 | tail -1 | cut -c$(test "$short" && echo "3,4,6,7,9,10" || echo "-10"))_$(echo "$file" | sed 's/2\?\([0-9]\{2,3\}\)-\([0-9]\{2\}\)\(-[0-9]\{2\}\)\?_\?//')"
done
2021-11-25 12:20:13 +00:00
# stat --format %y "$file" | cut -d' ' -f1