In trying to make a script into a drag-and-drop, this now errors out telling me it can’t create a folder (“Can’t make class «class cfol». Finder got an error: Can’t make class folder. (-2710”)". I’m not sure what it is I’m missing, but would appreciate any pointers.
on open sortzipPrep
tell application "Finder"
tell application "Finder"
set inputFolder to choose folder default location sortzipPrep with prompt "Select font folder to be zipped"
tell current application
set qpp to quoted form of POSIX path of inputFolder
do shell script "cd $(dirname " & qpp & ")
zip -r \"$(basename " & "_TYPEFACES" & ").zip\" \"$(basename " & qpp & ")\""
end tell
delete inputFolder
end tell
--create new hires folder
make new folder at sortzipPrep with properties {name:"HIRES"}
--set path to move to HIRES folder
set hiFiles to (sortzipPrep as string) & "HIRES"
-- move files to HIRES
set targetFiles to get every item of (entire contents of sortzipPrep) whose kind ≠"Folder"
--set targetFolder to hiFiles
move targetFiles to hiFiles
delete (every folder of sortzipPrep whose name is not "HIRES")
make new folder at sortzipPrep with properties {name:"PREVIEWS"}
--notify completion
display notification "FONTS ZIPPED AND FILES SORTED"
end tell
end open
I noticed you have a “Tell Finder” block inside a “Tell Finder” block.
I’m more partial to “System Events” for file manipulation
–edit-- I put it back to “Finder” to get it to work
here is my modified version.
I didn’t test it since I don’t have the file to test on.
Let me know if it works?
on open sortzipPrep
local targetFiles
set sortzipPrep to item 1 of sortzipPrep -- "on open creates a list of disk items"
set inputFolder to (choose folder default location sortzipPrep with prompt "Select font folder to be zipped")
set qpp to quoted form of POSIX path of inputFolder
do shell script "cd $(dirname " & qpp & ") zip -r \"$(basename " & "_TYPEFACES" & ").zip\" \"$(basename " & qpp & ")\""
tell application "Finder"
make new folder at (sortzipPrep as text) with properties {name:"HIRES"}
make new folder at (sortzipPrep as text) with properties {name:"PREVIEWS"}
delete folder inputFolder
--create new hires folder
--set path to move to HIRES folder
set hiFiles to (sortzipPrep as string) & "HIRES"
-- move files to HIRES
set targetFiles to get every item of (entire contents of folder sortzipPrep) whose kind ≠"Folder"
--set targetFolder to hiFiles
move targetFiles to hiFiles
delete (every folder of sortzipPrep whose name is not "HIRES")
--notify completion
display notification "FONTS ZIPPED AND FILES SORTED"
end tell
end open
on open sortzipPrep
local sortzipPrep
set sortzipPrep to item 1 of sortzipPrep -- "on open creates a list of disk items"
tell application "Finder"
--pick and zip font folder
set inputFolder to (choose folder default location sortzipPrep with prompt "Select font folder to be zipped")
set qpp to quoted form of POSIX path of inputFolder
do shell script "cd $(dirname " & qpp & ")
zip -r \"$(basename " & "_TYPEFACES" & ").zip\" \"$(basename " & qpp & ")\""
delete folder inputFolder
--create new hires folder
make new folder at (sortzipPrep as text) with properties {name:"HIRES"}
--set path to move to HIRES folder
set hiFiles to (sortzipPrep as string) & "HIRES"
-- move files to HIRES
set targetFiles to get every item of (entire contents of folder sortzipPrep) whose kind ≠"Folder"
--set targetFolder to hiFiles
move targetFiles to hiFiles
delete (every folder of sortzipPrep whose name is not "HIRES")
make new folder at (sortzipPrep as text) with properties {name:"PREVIEWS"}
--notify completion
display notification "FONTS ZIPPED AND FILES SORTED"
end tell
end open
Although the script might work there are a few confusions about wrong references.
After flattening sortzipPrep it’s an alias specifier.
In the Finder an alias can be used directly without extra file or folder specifier keywords.
And the result of a folder creation can be used as a reference, too
on open sortzipPrep
local sortzipPrep
set sortzipPrep to item 1 of sortzipPrep -- "on open creates a list of disk items"
tell application "Finder"
--pick and zip font folder
set inputFolder to (choose folder default location sortzipPrep with prompt "Select font folder to be zipped")
set qpp to quoted form of POSIX path of inputFolder
do shell script "cd $(dirname " & qpp & ")
zip -r \"$(basename " & "_TYPEFACES" & ").zip\" \"$(basename " & qpp & ")\""
delete folder inputFolder
--create new hires folder
set hiFiles to make new folder at sortzipPrep with properties {name:"HIRES"}
-- move files to HIRES
set targetFiles to get every item of (entire contents of sortzipPrep) whose kind ≠"Folder"
--set targetFolder to hiFiles
move targetFiles to hiFiles
delete (every folder of sortzipPrep whose name is not "HIRES")
make new folder at sortzipPrep with properties {name:"PREVIEWS"}
--notify completion
display notification "FONTS ZIPPED AND FILES SORTED"
end tell
end open