Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got many files which came from windows zipped file. The files has accents in names like:

"partyku?y no.doc" (this is the string displayed in linux terminal)

How to unpack or maybe rename with correct chars?

UPDATE:

Firstly i extract zip in 'win xp'.. result:

garbage in names

Next step, unzip in 'win 7'.. result:

perfect names.

So I downloaded 7z for windows and compressed as 7z and as a zip (both with 7z)

Then put files to linux and extract it with '7z x ..' on files..

7z spits correct names but .zip not.

I was lucky to have an access to 'win 7', what if not? Replacing chars like rody_o suggest?

share|improve this question
1  
And you're sure it's the filenames, and not, e.g., that your terminal font doesn't have good UTF-8 support? The names also look like that, e.g., on desktop or in a file browser window? –  user139706 Jul 11 '12 at 14:16
    
I checked it and it's not only terminal. –  xliiv Jul 11 '12 at 14:24
add comment

migrated from stackoverflow.com Jul 11 '12 at 20:59

This question came from our site for professional and enthusiast programmers.

3 Answers

Figure out which encoding the filenames are in and use convmv to rename them.

share|improve this answer
    
I used it but it told the files are utf8 already and they still wasn't well displayed. –  xliiv Jul 11 '12 at 14:08
    
There is a difference between the encoding of the files' names and the encoding of the files' contents. Most likely your terminal is UTF-8, so if the filenames aren't correctly displayed, they are not UTF-8. So that means that you should double-check that you have correctly used convmv –  Jo So Jul 11 '12 at 15:19
add comment

I suspect the real question here is "how do I transfer files using zip without corrupting non-ASCII filenames?". If this is the real problem that you are trying to solve, try using the "-UN=UTF8" command-line option to zip when you create the archive. This will force zip to store filenames using UTF-8, which should preserve non-ASCII characters.

share|improve this answer
    
What if someone else creates zip? 'Someone else' who is limited to mastered only windows zip? Is there any chance to uncompress it on linux AND have good names? :) –  xliiv Jul 11 '12 at 17:23
    
If the zip is created without UTF-8 support enabled, then the filenames will be corrupted when they are stored in the file. You can't recover them later, as the original name is not stored anywhere. This is a classic problem with the zip format, see linux.die.net/man/1/zip for a more thorough description. If you are limited to the version of zip that is built into Windows, I recommend sticking to ASCII filenames only. –  bta Jul 11 '12 at 18:01
add comment

Well, if you're sure that really is the filename and not some encoding conflict, then you can bulk-rename such files with

rename s/REGEX/REPLACEMENT/ *.doc

or, a slightly more aesthetic way,

rename s,REGEX,REPLACEMENT, *.doc

in which case you don't need to escape things like ?.

REGEX and REPLACEMENT are regular expressions -- rename is basically sed for file renaming.

When bulk-renaming with rename, it's always a good idea to run rename with the -n option before doing the actual renaming. This option means "dry-run", so just print what would be done if the -n were removed.

Be sure to read man rename and/or man sed before experimenting.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.