Given a group of files with the following naming convention:
datetime_restofname.txt
an example of which would be:
200906290700_somewordorphrase.txt
how could I batch change the mtime of the files to match the date and time in the filename?
Given a group of files with the following naming convention:
datetime_restofname.txt
an example of which would be:
200906290700_somewordorphrase.txt
how could I batch change the mtime of the files to match the date and time in the filename?
$ for f in *.txt; do touch -t `echo $f | cut -f1 -d _` "$f"; done
This will set the file modtime to the date string before the underscore.