cleanup script to put files into date folders


I made a backup-script which just dumps it’s files into 1 folder, but that got messy pretty quickly. I needed a script which could cleanup files (*.tgz) from a folder and put them into their respective date-folder.


cd /rootfolder/to/cleanup
for x in *.tgz; do
d=$(date -r "$x" +%Y-%m-%d)
mkdir -p "$d"
mv -- "$x" "$d/"

Leave a Reply

Your email address will not be published. Required fields are marked *