Applescript从其他文件创建和重命名文件

Applescript从其他文件创建和重命名文件,applescript,filenames,rename,automator,Applescript,Filenames,Rename,Automator,为了将.MOV文件(h.264)导入Final Cut Pro,我需要一个与.MOV文件名相同的对应.THM文件。是否可以使用AppleScript或Automator执行此操作?以下是我想做的: 创建已存在于我的硬盘上的“TEMPLATE.THM”文件的副本 使用.MOV文件名重命名“TEMPLATE.THM”文件 对包含.MOV文件的文件夹执行此操作,以便为具有相同文件名的每个.MOV文件创建一个.THM文件 G'day 这可能不是最快的方法,但我知道你还在等待答案,所以这里有一些东西可以让

为了将.MOV文件(h.264)导入Final Cut Pro,我需要一个与.MOV文件名相同的对应.THM文件。是否可以使用AppleScript或Automator执行此操作?以下是我想做的:

  • 创建已存在于我的硬盘上的“TEMPLATE.THM”文件的副本
  • 使用.MOV文件名重命名“TEMPLATE.THM”文件
  • 对包含.MOV文件的文件夹执行此操作,以便为具有相同文件名的每个.MOV文件创建一个.THM文件 G'day

    这可能不是最快的方法,但我知道你还在等待答案,所以这里有一些东西可以让你开始。在finder中选择所有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
    
    获取模板路径的最简单方法是在finder中选择模板并运行以下操作:

    tell application "Finder"
        set theFile to selection as string
    end tell
    
    这将把路径放在结果窗口中——只需将其复制到上面脚本的第一行即可

    希望有帮助

    m.