Batch Zip Folders And Name With Foldername+size

i all
From a HD structured this fashion (example)
ClassA/StudentnameA
ClassA/StudentnameB
and so on
ClassB/StudentnameA
ClassB/StudentnameB
and so on
ClassC/StudentnameA

etc
I hope to be able to select the CLASS folder and batch zip all the STUDENTNAME folders inside it naming the zipped file: StudentnameA+Foldersize
the foldersize should refer only to the visible items inside it, skipping the .DS_Store, .localized and all possible invisible items it may contain

I know there is an Automator function doing it. But I’d rather use Applescript for many reasons.

Thanks a lot

Model: MACPRO
Browser: Safari 537.73.11
Operating System: Mac OS X (10.8)

I did this attempt thanks to the help of a friend


tell application "Finder"
	set myFolders to every folder of (choose folder)
	set destinationPath to POSIX path of (container of (item 1 of myFolders) as string)
end tell
repeat with aFolder in myFolders
	tell application "Finder" to set filesize to size of files in the entire contents of aFolder as string
	set basename to do shell script "basename " & POSIX path of (aFolder as string)
	do shell script "ditto -c -k --sequesterRsrc --keepParent " & quoted form of POSIX path of (aFolder as string) & space & quoted form of (destinationPath & "-" & basename & filesize & ".zip")
end repeat

However I receive this error all the time. Could someone help please

tell application “Finder”
choose folder
→ alias “Hwork:ClassA:”
get every folder of alias “Hwork:ClassA:”
→ {}
Result:
error “Can’t make «class ctnr» of item 1 of {} into type string.” number -1700 from «class ctnr» of item 1 of {} to string

Also would it be possible to choose a destination folder for the Zipped Files?

Hi,

the error occurs if the folder list is empty, therefore there is no item 1