I recently wrote a Perl script, that renames the files in a directory according to the date, in the format “YYYYMMDD ##” where “##” is the running number.
Because I used to download the photos using the mobile apps like Weibo or Twitter, however the file names are almost random. This made me hard to organize these photos on my computer.
The artists (or celebrities) usually share a set of their photos, so when I download these photos, the files should have
mtime (modified time) in the correct order.
Yet, I don’t need to rename the file to the time precision like “HH:MM:SS”. I just need the date and followed by the running number, because it looks shorter.
Though we can just use the file browsers to sort the files according to the time, it is still inconvenient to browse the images by changing the sorting condition. Furthermore,
mtime can be changed, and this will void the purpose of the sorting.
Lastly, the randomized filename is just meaningless to me. Rename them according to the date is much more useful, in my opinion.
In my opinion, Perl is less famous like Python in the present day. But I prefer to use Perl, due to the popularity in most Linux distribution. For example Perl is the
base package of Arch Linux. Once I installed Arch Linux, I can run Perl script immediately.
Though Python is great, backward incompatibility sometimes causes issue, which I may need to maintain the script. If I write with Perl, I can pay less effort to maintain the script.
WARNING! And usage
As the script mentioned,
Rename is irreversible. Recommend to make a backup.
The usage is,
target_dir is the directory that contains the files you want to rename. It will not rename the files recursively.
PLEASE USE THE SCRIPT AT YOUR OWN RISK!!!
After renaming the files, a log file will be created. It is used just in case you want to revert the file name. (But you have to do this manually.)