1

给定一组具有以下命名约定的文件:

datetime_restofname.txt

一个例子是:

200906290700_somewordorphrase.txt

如何批量更改文件的 mtime 以匹配文件名中的日期和时间?

4

1 回答 1

7
$ for f in *.txt; do touch -t `echo $f | cut -f1 -d _` "$f"; done

这会将文件 modtime 设置为下划线之前的日期字符串。

于 2009-07-01T00:01:01.903 回答