Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have about 200+ shareware files in zip format that each contain a file called "FILE_ID.DIZ". I need to know how to rename each instance to lowercase "file_id.diz" without doing it manually - I've already gone that route and it's pretty time consuming. That file has to be lowercase because the BBS program I'm using ignores the FILE_ID.DIZ as a description since it is uppercase. If I manually change it to lowercase, the description is imported successfully.

I know that rar has a renaming switch, but then I'd have to batch convert all of the zip files to rar, and then back to zip. I'm not ruling that out entirely, but it seems like the long way around to resolving this.

I found the man page for "zip_rename", which looks like it might do the trick, but I have no idea how to actually implement it.

I refuse to do this on a Windows machine - I just can't and won't do it... it's the principle ;).

Anyway, thanks for your time!

share|improve this question
up vote 2 down vote accepted

This technique won't rename the file, but add a lowercase version of the .DIZ file. Hopefully it will be good enough for your purposes.

This takes advantage of zip's "add by default" functionality, in which if you specify an existing zip file, it will add files to it. So if you do:

zip file_id.diz

and exists, it will just add the file_id.diz file to the existing contents.

This is to be run in the directory where your zip files reside:

for i in  *zip; do rm FILE_ID.DIZ;  unzip "$i" FILE_ID.DIZ; mv FILE_ID.DIZ file_id.diz; zip -d "$i" FILE_ID.DIZ; zip "$i" file_id.diz; done

Note that for best results, none of the .zip file names should contain spaces.

You can also put this in a file, say, (and it looks nicer and easier to understand this way):

for i in  *zip; do
   unzip "$i" FILE_ID.DIZ
   mv FILE_ID.DIZ file_id.diz
   zip -d "$i" FILE_ID.DIZ
   zip "$i" file_id.diz

then you can run by saying, e.g. bash

share|improve this answer
Thanks! That worked perfectly. This is a great starting point for me. I'm going to see if I can figure out how to write a script to extract each archive to a temp folder, copy the FILE_ID.DIZ to file_id.diz, delete the FILE_ID.DIZ , re-zip the file and then empty the temp directory. – user73469 Jun 27 '12 at 12:48
You can delete files from a zipfile directly with zip -d. I've updated the script to make use of this feature. I suggest you back up your original zip files, whenever we delete stuff it's a good safety net to have :) – roadmr Jun 27 '12 at 13:58
That's fantastic! One thing I noticed is that the script puts a copy of "file_id.diz" in the working directory and also creates a file called "" - I called the script "runzip" for lack of creativity. I just added "rm" and "rm file_id.diz" and it took care of it. – user73469 Jun 28 '12 at 16:10

You can use the rename function of zipnote of info-zip:

for zip_filename in *.zip; do
    # Only process original zip files.
    if [ "${}" = "${zip_filename}" ] ; then
        # Create a copy which will be modified later.
        cp ${zip_filename} ${}

        # Get all filenames, change some of them on the fly and write them to the zip file.
        zipnote ${zip_filename} \
          | sed -e 's/^@ \(.*\)FILE_ID.DIZ/@ \1FILE_ID.DIZ\n@=\1file_id.diz/' \
          | zipnote -w ${}
share|improve this answer

Your Answer


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.