假设我在文件夹“A”中有以下文件:
“AAAAA 1x1”,“AAAAA 1x2”,“BBBBB 1x1”,“BBBBB 1x2”,“CCCCC 1x1”,“CCCCC 1x2”。
在文件夹“B”中,我有以下文件夹:
“AAAAA”,“BBBBB”,“CCCCC”。
我想要做的是将文件夹“A”中的所有“AAAAA”文件移动到文件夹“B”中的“AAAAA”,将“BBBBB”文件移动到文件夹“BBBBB”,依此类推。 / p>
如何使用Apple Script执行此操作?
答案 0 :(得分:1)
尝试在终端中运行这样的命令:
for f in A/*; do echo mv "$f" B/${f:2:5}; done
删除echo
以实际移动文件。
答案 1 :(得分:0)
尝试:
set folderA to "/Users/Joao/Desktop/A"
set folderB to "/Users/Joao/Desktop/B"
tell application "System Events"
set subFolders to folders of (folder folderB)
repeat with subfolderB in subFolders
move (files of folder folderA whose name starts with (name of subfolderB)) to (path of subfolderB)
end repeat
end tell
答案 2 :(得分:0)
这是代码(感谢MacScripter的一些优秀人员):
set sourceFolder to alias "SSD:Users:JPCanaverde:Documents:A"
set destinationFolder to alias "SSD:Users:JPCanaverde:Documents:B"
tell application "Finder"
repeat with aFolder in (get folders of destinationFolder)
set folderName to name of aFolder
set filesToMove to (files of sourceFolder whose name begins with folderName)
move filesToMove to (contents of aFolder)
end repeat
end tell