Created
December 29, 2020 04:52
-
-
Save pkozelka/3b464da98b01b447a0f1c3c80ae541da to your computer and use it in GitHub Desktop.
prefix filename with file's date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Indicated files will be renamed by prefixing with their modification date. | |
# Useful for photos from old devices that did not store metadata. | |
# This only prints the `mv` commands (preview); pipe it to `sh` to apply the changes | |
function filetime() { | |
local f=$1 | |
local t=$(stat -c %y "$f") | |
t=${t%% *} | |
echo ${t//-/} | |
} | |
for i in "$@"; do | |
i2="$(filetime $i)-$i" | |
echo "mv $i $i2" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment