【发布时间】:2014-02-15 17:21:53
【问题描述】:
我需要一些帮助来微调这个脚本。是否可以让此脚本根据文件的前两个字母匹配子文件夹?父文件夹将是“Shots”,其中包含具有唯一两个字母前缀“BA_Bikini_Atol”的子文件夹,其中包含这些文件夹中用于特定镜头 ba_0020、ba_0030 等的子文件夹。想要通过选择“shots”将文件 ba_0020_v0002 移动到 ba_0020 文件夹" 作为目标,脚本会在所有子文件夹中查找匹配项。想法?
set mgFilesFolder to (choose folder with prompt "Where are the files stored which you would like to move to the destination?")
set mgDestFolder to (choose folder with prompt "Where is the destination folder?")
tell application "System Events"
set folderList to name of folders of mgDestFolder
set fileList to name of files of mgFilesFolder
end tell
repeat with i from 1 to (count folderList)
set folderName to item i of folderList
set filesToMove to {}
repeat with j from 1 to (count fileList)
set filename to item j of fileList
if filename begins with folderName then
set end of filesToMove to alias ((mgFilesFolder as string) & filename)
end if
end repeat
tell application "Finder"
move filesToMove to alias ((mgDestFolder as string) & folderName & ":")
end tell
end repeat
【问题讨论】:
-
不完全重复,但这个问题显示了如何根据文件名的开头移动文件:stackoverflow.com/questions/18397954/…
-
Darrick - 这是我正在使用的脚本,效果很好,但是如何让脚本查找子文件夹以进行匹配?
标签: applescript