我是相当新的,虽然在过去的几周里我设法创建了几个基本脚本,但我似乎无法绕过这个:
到目前为止,我为这个过程整理的剧本是令人沮丧,邋and和彻头彻尾的可怜,所以我不敢在这里分享它们。
我的实验也导致项目列表导致顺序移动文件的问题。 代替: ValOne_1.wav ValOne_2.wav ValOne_3.wav ValOne_4.wav ValOne_5.wav
我得到: ValOne_1.wav ValOne_10.wav ValOne_100.wav ValOne_101.wav ValOne_102.wav
由于
答案 0 :(得分:2)
Finder有一个“排序”命令,因此您可以使用它来避免您提到的编号问题。它似乎按照你期望的方式对它们进行排序。因此,通过一些巧妙的编码,您的工作流程变得简单。请尝试以下方法。您只需要调整脚本中的前两个变量以满足您的需要,并且脚本的其余部分应该正常工作。
set filesPerFolder to 3
set newFolderBaseName to "StorageFolder_"
set chosenFolder to (choose folder) as text
tell application "Finder"
-- get the files from the chosen folder and sort them properly
set theFiles to files of folder chosenFolder
set sortedFilesList to sort theFiles by name
set theCounter to 1
repeat
-- calculate the list of files to move
-- also remove those files from the sortedFilesList
if (count of sortedFilesList) is greater than filesPerFolder then
set moveList to items 1 thru filesPerFolder of sortedFilesList
set sortedFilesList to items (filesPerFolder + 1) thru end of sortedFilesList
else
set moveList to sortedFilesList
set sortedFilesList to {}
end if
-- calculate the new folder information and make it
set newFolderName to newFolderBaseName & theCounter as text
set newFolderPath to chosenFolder & newFolderName
if not (exists folder newFolderPath) then
make new folder at folder chosenFolder with properties {name:newFolderName}
end if
-- move the moveList files
move moveList to folder newFolderPath
if sortedFilesList is {} then exit repeat
set theCounter to theCounter + 1
end repeat
end tell