On Unix-like operating systems, the zipnote command views, adds, or edits a zipfile’s comments. It also lets you rename files contained in the archive.

This page covers the Linux version of zipnote.

Description

Every file that is archived in the zip format may optionally contain comments, which are short notes or descriptions about individual files or the entire archive.

  • Description
  • Syntax
  • How zipnote works
  • Types of zipfile comments
  • Viewing a zipfile’s comments
  • Adding comments
  • Using zipnote to rename the files in your archive
  • Examples
  • Related commands
  • Linux commands help

When you create a zipfile with the zip utility, you can add comments about individual files using zip’s –entry-comments option. You can also add a comment about the entire archive using zip’s –archive-comment option. These comments will be written to the zipfile as part of the archiving process.

If you want to add comments after a zipfile has already been created, however, you can use zipnote.

Syntax

zipnote [-w] [-b path] [-h] [-v] [-L] zipfile

Options

How zipnote works

By default, zipnote will dump a zipfile’s comments to standard output.

If you want to make changes, you can redirect this output to a file, edit it manually, and then use zipnote to read in your changes and write them to the zipfile.

You can also use zipnote to rename the files in the archive by making special edits during this process.

Types of zipfile comments

“Archive comments” describe the archive as a whole, and are shown when a user views the contents of an archive, and also when a user extracts files from the archive.

“Entry comments” describe individual files in the archive. They are displayed when a user views the contents of an archive, but are usually not shown when the files are extracted.

Both these types of comments can be added or modified using zipnote.

Viewing a zipfile’s comments

Let’s say you have a zipfile called files.zip, which contains two files: file1 and file2. You can view files.zip’s comments using the following command:

zipnote files.zip

The output looks like this:

@ file1 @ (comment above this line) @ file2 @ (comment above this line) @ (zip file comment below this line)

This shows us that there are two files, file1 and file2, and that there are no comments in the file. (If there were, we would see them here.)

If we view a list of the files in the archive using the -l option of unzip, like this:

unzip -l files.txt

…our file list looks like this:

Archive: files.zip Length Date Time Name


    0  2014-09-27 15:48   file1
    0  2014-09-27 15:48   file2

    0                     2 files

If there were descriptions for the archive or the individual files, they would appear here.

Adding comments

To change the comments in files.zip using zipnote, we first need to capture zipnote’s output to a file. Let’s redirect the output to a file called comments.txt:

zipnote files.zip > comments.txt

Now, open the newly-created comments.txt file in your favorite text editor, adding lines so that it looks like this:

@ file1 This is the first file in our archive. @ (comment above this line) @ file2 This is the second file in our archive. @ (comment above this line) @ (zip file comment below this line) This archive contains two files.

Save the file and exit your text editor.

Next, we run zipnote with the -w option. The command looks like this:

zipnote -w files.zip < comments.txt

This command says, “use the contents of comments.txt as input for zipnote, and write (-w) that data as the new comments of files.zip.” When this command is run, our edits replace the comments in files.zip.

Let’s use zipnote again, to check that our changes are written:

We can also use unzip -l to list the archive contents, and we’ll see our new comments:

unzip -l files.zip

Archive: files.zip This archive contains two files. Length Date Time Name


    0  2014-09-27 15:48   file1

This is the first file in our archive. 0 2014-09-27 15:48 file2 This is the second file in our archive.


    0                     2 files

Additionally, when we extract the files from the archive with unzip, it shows us the archive comment with the rest of the output:

unzip files.zip

Archive: files.zip This archive contains two files. extracting: file1
extracting: file2

Using zipnote to rename the files in your archive

It’s possible, in your edits to the comments, to rename the archived files themselves. For instance, here is the comments.txt file we were working with:

If we open this up in our editor again, we can insert a line beneath the file name and above the comment in the form “@=newfilename”. For instance, let’s rename our files file1 and file2 to file-one and file-two, respectively. We do this by adding two lines so that comments.txt looks like this:

@ file1 @=file-one This is the first file in our archive. @ (comment above this line) @ file2 @=file-two This is the second file in our archive. @ (comment above this line) @ (zip file comment below this line) This archive contains two files.

Now we write our changes using zipnote -w, as we did before:

…and check our changes using unzip -l:

Archive: files.zip This archive contains two files. Length Date Time Name


    0  2014-09-27 15:48   file-one

This is the first file in our archive. 0 2014-09-27 15:48 file-two This is the second file in our archive.


    0                     2 files

…and voilà, the files are renamed.

Examples

zipnote myarchive.zip

Display details about myarchive.zip, including any comments, in a zipnote-specific format.

There is no undo function for any of the changes you make with zipnote, so double check your comments file before writing to the archive! Any changes you make with the -w option are permanent.

zipnote myarchive.zip > mycommentfile.txt

Redirect the output of zipnote to the file mycommentfile.txt, writing the comment information to that file.

zipnote -w myarchive.zip < mycommentfile.txt

Redirect the contents of mycommentfile.txt to zipnote, which takes them as input and writes them (-w) as comments to myarchive.zip.

unzip — List, test and extract compressed files in a zip archive.zip — A compression and archiving utility.zipcloak — Encrypt files within an existing zip archive.zipsplit — Split a single zip archive into a set of smaller zip files.