zip script

Hi, I’m having trouble with a script that zips files. If I have any spaces in the path the script doesn’t work.

This works fine:

set SourceFile to "/Volumes/HD2/testfile.pdf"
set DestinationFile to "/Volumes/HD2/testfile.pdf.zip"

do shell script "zip -r -j " & DestinationFile & " " & SourceFile & "* -x *.DS_Store"

This doesn’t work:

set SourceFile to "/Volumes/HD2/test file.pdf"
set DestinationFile to "/Volumes/HD2/test file.pdf.zip"

do shell script "zip -r -j " & DestinationFile & " " & SourceFile & "* -x *.DS_Store"

How can I modify the script so that it accepts spaces in the path?

This will work too :


set SourceFile to "/Volumes/HD2/test file.pdf"
set DestinationFile to "/Volumes/HD2/test file.pdf.zip"
set SourceFile to quoted form of SourceFile
set DestinationFile to quoted form of DestinationFile
do shell script "zip -r -j " & DestinationFile & " " & SourceFile & "* -x *.DS_Store"

Yvan KOENIG (VALLAURIS, France) vendredi 22 février 2013 10:58:52

Thx, it works!

Next problem is that my Scandinavian letters Ã¥, ä, ö doesn’t work in the path.
Is there an easy solution for this?