[英]Use “Touch -r” for several files with automator
I use "MacOS X Yosemite (10.10.4)" 我使用“ MacOS X Yosemite(10.10.4)”
I've converted video mts files to mov files using QuickTime, but the new file created doesn't preserve original Creation Date. 我已经使用QuickTime将视频mts文件转换为mov文件,但是创建的新文件并未保留原始的创建日期。
fileA.mts --> Creation Date: 07/02/2010 10:51
fileA.mts->创建日期:2010年7月2日10:51
fileA_converted.mov --> Creation Date: Today 8:35
fileA_converted.mov->创建日期:今天8:35
I'd like to change the Creation Date attribute of several files, using the date of the original files. 我想使用原始文件的日期更改多个文件的创建日期属性。 I know I can do this by using Terminal "Touch" command in order to this:
我知道我可以通过使用终端“ Touch”命令来做到这一点:
touch -r fileA.mts fileA_converted.mov
touch -r fileB.mts fileB_converted.mov
As I have more than 200 files to change Creation Date, is it possible to automate this using automator Script Shell action, or any other way? 由于我有200多个文件要更改“创建日期”,是否可以使用自动脚本外壳程序操作或其他方法自动执行此操作?
Execute below command when we have all original and converted files in same folder 当所有原始文件和转换后的文件都放在同一文件夹中时,请执行以下命令
ls | grep ".mts" | awk -F. '{print $0" "$1"_converted.mov"}' | xargs touch -r
when we have different folder run below command on path where .mts files are present and add absolute path before $1 just like I have added /home/convertedfiles/ 当我们在存在.mts文件的路径上在命令下运行以下文件夹并在$ 1之前添加绝对路径时,就像我添加了/ home / convertedfiles /
ls | grep ".mts" | awk -F. '{print $0" /home/convertedfiles/"$1"_converted.mov"}' | xargs touch -r
Like this in the bash
shell - which is what you get in Terminal
(untested): 在
bash
shell中是这样的-这是您在Terminal
获得的(未经测试的):
#!/bin/bash
for orig in *.mts; do
# Generate new name from old one
new="${orig/.mts/_converted.mov}"
echo touch -r "$orig" "$new"
done
Save the above in a file called doDates
and then type this in the Terminal 将以上内容保存在名为
doDates
的文件中,然后在终端中键入
chmod +x doDates # make the script executable
./doDates # run the script
Sample output 样品输出
touch -r Freddy Frog.mts Freddy Frog_converted.mov
touch -r fileA.mts fileA_converted.mov
At the moment it does nothing, but run it, see if you like what it says, and then remove the word echo
and run it again if all looks ok. 目前,它什么也没做,但是运行它,看是否喜欢它所说的内容,然后删除
echo
一词,如果一切正常,则再次运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.