How to recursively zip utf-8 files and folders from a batch file?

Posted on

QUESTION :

I have a folder named “Attachments2”. I’m working in windows 7 and am using zip.exe downloaded from cygwin to zip this folder.

In this folder there are folders and files which have Hebrew characters in their names and content (in the files’ content that is).

The files and folders’ names are not preserved as the origin but the files’ content is.

Please help.

Regrards,
Omer.

ANSWER :

You could use the free commandline tool 7z.exe from 7zip.

The version history of 7zip explicitely mentions its UTF-8 support:

- Unicode (UTF-8) support for filenames in .ZIP archives. Now there are 3 modes:
    1) Default mode: 7-Zip uses UTF-8, if the local code page doesn't contain required symbols.
    2) -mcu switch:  7-Zip uses UTF-8, if there are non-ASCII symbols.
    3) -mcl switch:  7-Zip uses local code page.

A recursive zip command with 7zip looks like:

7z.exe a -mcl -tzip attachments.zip -r Attachments2*.*

Note:
7zip’s own format .7z does not support codepages. You have to use the -tzip parameter to select the .zip archive format.

Leave a Reply

Your email address will not be published.