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

0

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.

omer bach

Posted 2013-08-06T09:05:43.690

Reputation: 113

1"The files and folders' names are preserved as the origin but the files' content is" ?? Please edit – Jan Doggen – 2013-08-06T09:27:36.793

Do you mean "...but the files' content isn't."? If so, what's wrong with it. – martineau – 2013-08-06T09:30:44.270

thanks, I meant that the file names and folders are not preserved as the origin but the content is – omer bach – 2013-08-06T09:45:50.067

Answers

1

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.

Axel Kemper

Posted 2013-08-06T09:05:43.690

Reputation: 2 892

Tried it and it didn't work (files and folder names are gybrish)... any ideas ? – omer bach – 2013-08-07T11:20:07.917

Which combination of switches have you tried? Please post the complete commandline. – Axel Kemper – 2013-08-07T11:22:13.630

7z.exe a -mcu -tzip attachments333.zip -r 2013-08-07_10-16-32*.* – omer bach – 2013-08-07T11:23:31.927

it is backslash and then . at the end, dont know why the it is not shown – omer bach – 2013-08-07T11:24:55.323

I tried the same command you posted just with different values – omer bach – 2013-08-07T11:29:36.683

Are you sure that the files names are actually garbled? Or could it be that you only get a wrong display of the names? 7z.exe has an additional parameter -scsUTF-8 to list UTF-8 encoded names. You could try the switch -mcl rather than -mcu during archiving. – Axel Kemper – 2013-08-07T11:30:46.463

That's good news! – Axel Kemper – 2013-08-07T12:24:12.207