【问题标题】:Applescript create and rename file from other filesApplescript 从其他文件创建和重命名文件
【发布时间】:2012-01-03 15:30:25
【问题描述】:
为了将 .MOV 文件 (h.264) 导入 Final Cut Pro,我需要一个与 .MOV 文件名相同的对应 .THM 文件。是否可以使用 AppleScript 或 Automator 执行此操作?这是我想做的:
- 创建一个已存在于我的 HD 上的“TEMPLATE.THM”文件的副本
- 使用 .MOV 文件名重命名“TEMPLATE.THM”文件
- 对 .MOV 文件的文件夹执行此操作,以便为每个具有相同文件名的 .MOV 文件创建一个 .THM 文件。
【问题讨论】:
标签:
applescript
filenames
rename
automator
【解决方案1】:
G'day
这可能不是最快的方法 - 但我看到您仍在等待答案 - 所以这里有一些可以帮助您入门的方法。在查找器中选择所有 MOV 文件并在脚本编辑器中运行。
set theTemplate to "Macintosh HD:Users:[user name]:[folder:location]:TEMPLATE.THM"
tell application "Finder"
set theFiles to selection
repeat with thisFile in theFiles
set thisName to name of thisFile
set theFolder to container of thisFile
set newFile to duplicate theTemplate to theFolder
set text item delimiters of AppleScript to "."
set thisName to text item 1 of thisName
set text item delimiters of AppleScript to ""
set newName to (thisName & ".THM")
set name of newFile to newName
end repeat
end tell
获取模板路径的最简单方法是在查找器中选择它并运行:
tell application "Finder"
set theFile to selection as string
end tell
这会将路径放在结果窗口中 - 只需将其复制到上述脚本的第一行即可。
希望有帮助
米。