property deleteOriginal : false
on open theseFolders
repeat with oneFolder in theseFolders
--commented the line below so that script can work both on files and folders
--if (folder of (info for oneFolder)) then
tell (POSIX path of oneFolder) to set {source, destination} to {it, it's text 1 thru -2 & ".zip"}
do shell script ("/usr/bin/ditto -c -k -rsrc --keepParent " & quoted form of source & " " & quoted form of destination)
if deleteOriginal then do shell script "rm -r " & quoted form of source
--end if
end repeat
end open
I got this script from:
http://macscripter.net/viewtopic.php?pid=84453
The problem:
i compressed a file in my “Desktop” folder named “New TextEdit Document.txt”
An archive with the name "New TextEdit Document.tx.zip" is created.
When I extracted it, I got a folder named “Desktop” and “New TextEdit Document.txt” inside it which does not make sense to me. (Probably, it was done to suit the needs of the user in that thread)
It should have been simply “New TextEdit Document.txt” (without the Desktop folder) and the archive name should have only been “New TextEdit Document.zip”.
Can someone fix it in such a way that folder hierarchies are maintained but not unnecessarily like in the above case (i.e. the Desktop folder) and secondly the names?
Thanks in advance.