move-year - A minute tool to help me
Time progresses on its own, which manifests itself in timestamps in filenames increasing. Such files are files from the tax office, bank statements and other stuff I download from such websites. I like to have them moved from the Downloads directory into directories that are in my backup run, and already have a script that reacts to such downloads being completed.
This script previously dumped the files in the root directory for documents of my bank or the tax office via
mv -i ~/Downloads/bank-statement-2022-01-01.pdf ~/Documents/finance/my-bank/
mv -i ~/Downloads/tax-report-01012022.pdf ~/Documents/finance/taxes/
So from time to time, I went through ~/Documents/finance/my-bank/
and
moved the files into directories according to the year they were in.
But I realized that a small tool can do that automatically and also create the directories directly. And ideally, I don't need to tell the tool very much at all:
move-year --create -ymd -i ~/Downloads/bank-statement-2022-01-01.pdf ~/Documents/finance/my-bank/
move-year --create -dmy -i ~/Downloads/tax-report-31112021.pdf ~/Documents/finance/taxes/
This way, the files will automatically land in the directories ~/Documents/finance/my-bank/2022
and ~/Documents/finance/taxes/2021
.
The tool is not yet on CPAN, but it lives on Github