Prefix a file name with its modification date
The following simple Bash script adds a year-month-date string to the file name, which makes its time stamp more apparent in a file explorer. Also note that in the grep
command, the Perl-compatible regular expression is adopted.
#!/bin/bash
modification_date=$(ls -l "$1" --full-time | grep -P "\d{4}-\d{2}-\d{2}" -o)
mv "$1" "$modification_date-$1"