0
我已經完成了這個腳本,根據它們的前6個字符串將文件組織到子文件夾中。例如,將位於名爲"bjaaahd"
的子文件夾中。 此腳本已在虛擬文件上進行了測試,以檢查其可行性。但現在,試圖測試真正的任務。它不按預期工作。 這些文件以這種形式出現"_londondire_123455-901-34"
等此代碼的分隔符添加/修改
我希望「_londondire」部分僅作爲文件夾並按該名稱進行組織。換句話說,只有沒有數字的名字。 我讀過關於分隔符的內容,但對於上帝的愛,我不明白。
--script begins
on run
set theFolder to ""
set fileList to {}
set theTarget to ""
set theString to ""
tell application "Finder"
set theFolder to (choose folder with prompt "Choose containing folder:" without invisibles and multiple selections allowed)
set fileList to every file of theFolder
repeat with i in fileList
name of i as text
set theString to text 1 thru 6 of result
try
set theTarget to ((theFolder as text) & theString) as alias
move i to theTarget
on error
make new folder at theFolder with properties {name:theString}
move i to result
end try
end repeat
end tell
end run
--script ends
我該如何做到這一點?
萬一有多個相同樣式的文件,例如e,_londondire,_Parisdire等? –
該代碼通過下劃線字符分割任何字符串。下劃線的數量很重要,而不是整個文本文本 – vadian
太棒了非常感謝你!乾杯! –