bin: utilities for preparing backups

This commit is contained in:
xeruf 2021-11-25 13:20:13 +01:00
parent d8c7616eb0
commit 4fe9e9cf64
3 changed files with 13 additions and 2 deletions

5
.local/bin/scripts/cachetag Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
echo 'Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by (application name).
# For information about cache directory tags, see:
# https://bford.info/cachedir/'>CACHEDIR.TAG

3
.local/bin/scripts/latest Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh -e
# Displays the latest files in the given directory or pwd
find "$1" -maxdepth 4 -type f -printf '%TF %f\n' | sort -r | head

View File

@ -1,5 +1,8 @@
#!/bin/sh
#!/bin/sh -e
# Add the modification date in front of the filename
IFS='\n'
for file
do mv --verbose --interactive "$file" "$(stat --format %y "$file" | cut -d' ' -f1)_$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