I’m puzzled;
Here it works flawlessly. Here is the log report:
tell application “AppleScript Editor”
choose folder with prompt “Create ZIP files of every file in selected folder(s):” with multiple selections allowed
→ {alias “Macintosh HD:Users:me:Desktop:dossier sans titre:”}
end tell
tell current application
path to desktop
→ alias “Macintosh HD:Users:me:Desktop:”
current date
→ date “mercredi 21 août 2013 09:45:47”
end tell
tell application “System Events”
make new folder at end of alias “Macintosh HD:Users:me:Desktop:” with properties {name:“zipped on 20130821_094547”}
→ folder “Macintosh HD:Users:me:Desktop:zipped on 20130821_094547:”
get path of folder “Macintosh HD:Users:me:Desktop:zipped on 20130821_094547:”
→ “Macintosh HD:Users:me:Desktop:zipped on 20130821_094547:”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ folder
get name of every disk item of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:” whose visible = true
→ {“extract 5digits numbers.app”, “get ID.applescript”, “Graph, manuel.doc”, “Graph, manuel.pages”, “imbécillité.doc”, “imbécillité.pages”, “job 1 Folder”, “job 2 Folder”, “System_fonts.doc”, “System_fonts.pages”}
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get path of container of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “Macintosh HD:Users:me:Desktop:”
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:extract 5digits numbers.app”
→ file package
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:get ID.applescript”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:Graph, manuel.doc”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:Graph, manuel.pages”
→ file package
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:imbécillité.doc”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:imbécillité.pages”
→ file package
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder”
→ folder
get name of every disk item of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:” whose visible = true
→ {“about GREP - more.doc”, “about GREP - more.pages”, “Lion DiskMaker.doc”, “Lion DiskMaker.pages”, “zdossier1-1”}
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:”
→ “job 1 Folder”
get path of container of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:”
→ “Macintosh HD:Users:me:Desktop:dossier sans titre:”
end tell
tell current application
do shell script “/usr/bin/python -c "import sys; print unicode(sys.argv[1], ‘utf8’).lower().replace(’ ‘,’-').encode(‘utf8’)" ‘job 1 Folder’”
→ “job-1-folder”
do shell script “ditto -ck ‘/Users/me/Desktop/dossier sans titre/job 1 Folder/’ ‘/Users/me/Desktop/zipped on 20130821_094547/job-1-folder.zip’”
→ “”
end tell
tell application “System Events”
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:”
→ “job 1 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:about GREP - more.doc”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:”
→ “job 1 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:about GREP - more.pages”
→ file package
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:”
→ “job 1 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:Lion DiskMaker.doc”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:”
→ “job 1 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:Lion DiskMaker.pages”
→ file package
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:”
→ “job 1 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:zdossier1-1”
→ folder
get name of every disk item of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:zdossier1-1:” whose visible = true
→ {“Tournette.doc”, “Tournette.pages”}
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:zdossier1-1:”
→ “zdossier1-1”
get path of container of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:zdossier1-1:”
→ “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:”
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:zdossier1-1:”
→ “zdossier1-1”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:zdossier1-1:Tournette.doc”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:zdossier1-1:”
→ “zdossier1-1”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 1 Folder:zdossier1-1:Tournette.pages”
→ file package
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder”
→ folder
get name of every disk item of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:” whose visible = true
→ {“about GREP - more.doc”, “about GREP - more.pages”, “Lion DiskMaker.doc”, “Lion DiskMaker.pages”, “zdossier1-1”}
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:”
→ “job 2 Folder”
get path of container of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:”
→ “Macintosh HD:Users:me:Desktop:dossier sans titre:”
end tell
tell current application
do shell script “/usr/bin/python -c "import sys; print unicode(sys.argv[1], ‘utf8’).lower().replace(’ ‘,’-').encode(‘utf8’)" ‘job 2 Folder’”
→ “job-2-folder”
do shell script “ditto -ck ‘/Users/me/Desktop/dossier sans titre/job 2 Folder/’ ‘/Users/me/Desktop/zipped on 20130821_094547/job-2-folder.zip’”
→ “”
end tell
tell application “System Events”
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:”
→ “job 2 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:about GREP - more.doc”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:”
→ “job 2 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:about GREP - more.pages”
→ file package
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:”
→ “job 2 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:Lion DiskMaker.doc”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:”
→ “job 2 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:Lion DiskMaker.pages”
→ file package
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:”
→ “job 2 Folder”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:zdossier1-1”
→ folder
get name of every disk item of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:zdossier1-1:” whose visible = true
→ {“Tournette.doc”, “Tournette.pages”}
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:zdossier1-1:”
→ “zdossier1-1”
get path of container of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:zdossier1-1:”
→ “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:”
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:zdossier1-1:”
→ “zdossier1-1”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:zdossier1-1:Tournette.doc”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:zdossier1-1:”
→ “zdossier1-1”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:job 2 Folder:zdossier1-1:Tournette.pages”
→ file package
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:System_fonts.doc”
→ file
get name of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:”
→ “dossier sans titre”
get class of disk item “Macintosh HD:Users:me:Desktop:dossier sans titre:System_fonts.pages”
→ file package
end tell
Résultat :
“”
And the contents of the dedicated folder is :
job-1-folder.zip
job-2-folder.zip
May you check that your folder names are really matching what you described which is :
starts with “job "
ends with " folder”
I tested the script four ways :
(1) I ran it and choose the folder embedding the different job folders.
(2) I ran it and choose the two job folders
(3) dropped the folder embedding the folder on the icon of the script saved as an application (droplet)
(3) dropped the two job folders on the icon of the script saved as an application (droplet)
I made a last test replacing the unix command name by ditta to check the behavior when the command supposed to zip failed. I got the logical report :
Error while creating ZIP file. (127)sh: ditta: command not found
Error while creating ZIP file. (127)sh: ditta: command not found
This is why I assume that the folder names aren’t matching the defined rule.
In such case,
(a) the target folder is created
(b) the script doesn’t find folder matching the rules so it zip nothing
(c) nothing failed in the process so there is no reason to create a report.
If you want I may add a piece of code counting the zipped folders and issuing a report not only if something failed but if the count is zero.
KOENIG Yvan (VALLAURIS, France) mercredi 21 août 2013 09:52:02