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 doom.zip file_id.diz
and doom.zip
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, rename.sh
(and it looks nicer and easier to understand this way):
#!/bin/bash
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
then you can run by saying, e.g. bash rename.sh
Use file <
redirection
zip files.zip -@ < zip.lst
Or you could skip the list and just glob
zip files.zip *.txt *.jpg
thanks steeldriver
Historical Answer
I'm glad it's OK to answer my own question because I wanted to chronicle my turmoil in hopes that others following behind in my trail of tears could be spared by searching some key words.
Eventually, I discovered the right answer, but it was posted to the wrong question.
A couple points of clarity:
- The manual isn't referring to a literal list as in a file, but rather literally to listing the files out on the console.
- It's understandable that someone might be misled into thinking that
foo
referred to the file list, but it's actually intended to represent the name of the output zip file.
- The list of files is omitted in the example because it's using the
-@
switch, which demonstrates it "takes the list of input files from standard input instead of from the command line"
Understanding this, we are now armed with a variety of ways to accomplish the goal.
Firstly using the file list we created, we can read out the list with cat
and redirect the output with a pipe as standard input to zip:
cat zip.lst | zip -@ files.zip
adding: file1.txt (stored 0%)
adding: file2.txt (stored 0%)
adding: file3.txt (stored 0%)
adding: file.jpg (stored 0%)
adding: test.jpg (stored 0%)
Seeing that adding: ...
for each file is certainly a good sign, but we've had our hopes up before, so let's just confirm:
unzip -l files.zip
Archive: files.zip
Length Date Time Name
--------- ---------- ----- ----
0 2016-05-24 14:54 file1.txt
0 2016-05-24 14:54 file2.txt
0 2016-05-24 14:54 file3.txt
0 2016-05-24 15:00 file.jpg
0 2016-05-24 14:59 test.jpg
--------- -------
0 5 files
SWEET! But who wants to create a onetime-use list anyway? That's an awful round-about way of solving this particular scenario. It would be better to get a list from ls
and pipe that to zip:
ls | zip -@ files.zip
adding: file1.txt (stored 0%)
adding: file2.txt (stored 0%)
adding: file3.txt (stored 0%)
adding: file.jpg (stored 0%)
adding: test.jpg (stored 0%)
Fabulous! Now let's create filters with the awesome power of grep
to just zip up the jpg's for instance:
ls | grep .jpg | zip -@ images.zip
adding: file.jpg (stored 0%)
adding: test.jpg (stored 0%)
Or just files beginning with "file"
ls | grep file. | zip -@ files.zip
adding: file1.txt (stored 0%)
adding: file2.txt (stored 0%)
adding: file3.txt (stored 0%)
adding: file.jpg (stored 0%)
Best Answer
For a GUI I'd say the easiest way is a nautilus script. The main line of which would be:
It works in bash/dash just as easy. In nautilus the whole thing would look like this: