0
我有超過200張照片。我想給的AppleScript:AppleScript將每個文件移動到新文件夾中
- 每個基於文件
- 移動的文件的名稱本200張的創建新的文件夾進去
這樣即。 XXX.jpg進入XXX文件夾。
任務或多或少簡單,但我在mac論壇上找到的所有aplescript代碼都過時了。 我是在山獅的最新版本
我有超過200張照片。我想給的AppleScript:AppleScript將每個文件移動到新文件夾中
這樣即。 XXX.jpg進入XXX文件夾。
任務或多或少簡單,但我在mac論壇上找到的所有aplescript代碼都過時了。 我是在山獅的最新版本
嘗試:
set myFolder to (choose folder)
tell application "Finder" to set myFiles to files of myFolder as alias list
repeat with aFile in myFiles
set bName to my baseName(aFile)
tell application "Finder"
set folderExists to exists folder bName of myFolder
if not folderExists then make new folder at myFolder with properties {name:bName}
move aFile to folder bName of myFolder
end tell
end repeat
on baseName(myFile)
tell application "System Events" to set {fileName, fileExt} to {name, name extension} of myFile
return text 1 thru ((get offset of "." & fileExt in fileName) - 1) of fileName
end baseName
編輯
set myFolder to findFolder()
tell application "Finder" to set myFiles to files of myFolder as alias list
repeat with aFile in myFiles
set bName to my baseName(aFile)
tell application "Finder"
set folderExists to exists folder bName of myFolder
if not folderExists then make new folder at myFolder with properties {name:bName}
move aFile to folder bName of myFolder
end tell
end repeat
---------------- HANDLERS ----------------
on baseName(myFile)
tell application "System Events" to set {fileName, fileExt} to {name, name extension} of myFile
return text 1 thru ((get offset of "." & fileExt in fileName) - 1) of fileName
end baseName
on findFolder()
activate application "SystemUIServer"
-- Bug pointed out by Lauri Ranta http://www.openradar.me/9406282
tell application "Finder"
activate
set mySelection to (get selection)
if mySelection ≠ {} then
set mySelection to first item of (get selection)
if mySelection's class = folder then
set currentFolder to mySelection
else if mySelection's class = document file then
set currentFolder to parent of mySelection
else if mySelection's class = alias file then
set currentFolder to original item of mySelection
end if
else
set currentFolder to target of front Finder window
end if
end tell
return (currentFolder as alias)
end findFolder
感謝名單。可能以「我的文件夾」是查找器顯示的方式進行調整?又名我打開文件夾我nfinder,這是工作應該去的文件夾。會更通用,然後 – user2341292 2013-05-13 03:16:16
請參閱我編輯的答案。 – adayzdone 2013-05-13 11:40:12
thanx那樣做! – user2341292 2013-05-13 15:13:03