0

假设我在文件夹“A”中有以下文件:

“AAAAA 1x1”、“AAAAA 1x2”、“BBBBB 1x1”、“BBBBB 1x2”、“CCCCC 1x1”、“CCCCC 1x2”。

在文件夹“B”中,我有以下文件夹:

“AAAAA”、“BBBBB”、“CCCCC”。

我想做的是将文件夹“A”中的所有“AAAAA”文件移动到文件夹“B”中的文件夹“AAAAA”,将“BBBBB”文件移动到文件夹“BBBBB”,依此类推。

我将如何使用 Apple Script 执行此操作?

4

3 回答 3

1

尝试在终端中运行这样的命令:

for f in A/*; do echo mv "$f" B/${f:2:5}; done

删除echo以实际移动文件。

于 2013-11-03T19:18:42.917 回答
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
于 2013-11-04T14:38:02.593 回答
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
于 2013-11-04T05:31:06.410 回答