Mil*_*lbe 1 bash filenames timestamp
给定一组具有以下命名约定的文件:
datetime_restofname.txt
一个例子是:
200906290700_somewordorphrase.txt
我怎么能批量更改文件的mtime以匹配文件名中的日期和时间?
$ for f in *.txt; do touch -t `echo $f | cut -f1 -d _` "$f"; done
Run Code Online (Sandbox Code Playgroud)
这会将文件modtime设置为下划线之前的日期字符串.