Untitled
unknown
plain_text
a year ago
2.4 kB
1
Indexable
Never
on run {input, parameters} try set theFolders to input repeat with currentFolder in theFolders tell application "Finder" set currentFolderName to displayed name of folder currentFolder set editFolder to (currentFolder as text) & "_EDIT:" -- Create the _EDIT folder if it doesn't exist if not (exists folder editFolder) then make new folder at currentFolder with properties {name:"_EDIT"} end if end tell set currentFolderPath to quoted form of (POSIX path of currentFolder as string) set editFolderPath to quoted form of (POSIX path of editFolder as string) --set theCMD to "find " & currentFolder & " -type f -name '*.jpg' -exec mv {} " & editFolderPath & " \\;" set theCMD to "find " & currentFolderPath & " -maxdepth 1 -type f \\( -name '*.jpg' -o -name '*.jpeg' -o -name '*.JPG' \\) -exec mv {} " & editFolderPath & " \\;" do shell script theCMD --rename folders tell application "Finder" set theSubFolders to every folder of folder (currentFolder as string) end tell repeat with currentSubFolder in theSubFolders set theCMD to "find " & (quoted form of (POSIX path of (currentSubFolder as string))) & " -type f \\( -name '*.jpg' -o -name '*.jpeg' -o -name '*.JPG' \\)" set theResult to do shell script theCMD tell application "Finder" if theResult is not "" then set name of currentSubFolder to (currentFolderName & " " & name of currentSubFolder as string) end if end tell end repeat --move folders tell application "Finder" set theSubFolders to every folder of folder (currentFolder as string) end tell repeat with currentSubFolder in theSubFolders set theCMD to "find " & (quoted form of (POSIX path of (currentSubFolder as string))) & " -type f \\( -name '*.jpg' -o -name '*.jpeg' -o -name '*.JPG' \\)" set theResult to do shell script theCMD if theResult is not "" then tell application "Finder" duplicate currentSubFolder to folder (POSIX file "/Users/simoneliasson/Dropbox/Fotograf Simon Eliasson AB - JPG" as string) replacing yes --duplicate currentSubFolder to folder (POSIX file "/Users/aliahmad/Work/Fotograf Simon Eliasson AB - JPG" as string) replacing yes end tell end if end repeat end repeat on error errMsg display dialog "ERROR: " & errMsg --error handling end try end run