Bash script to prepend a file with the date
parent
7bafd4c581
commit
074014ac30
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function datemv {
|
||||
if [[ $(basename "$1") == $(stat -c "%y" "$1" | cut -d " " -f1)* ]]; then
|
||||
echo "Do nothing with '$1'"
|
||||
else
|
||||
mv -v "$1" "$(dirname "$1")/$(stat -c "%y" "$1" | cut -d " " -f1)_$(basename "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -d $1 ]; then
|
||||
for file in $(find "$1" -type f | grep -vP "\/\d{4}-\d{2}-\d{2}"); do
|
||||
datemv "$file"
|
||||
done
|
||||
else
|
||||
echo "Directory not found '$1'"
|
||||
exit
|
||||
fi
|
||||
|
Loading…
Reference in New Issue