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
Best Answer
For each file
a_file
in current directory renamea_file
to lower case.For upper case reverse the arguments to
[:lower:] [:upper:]
tr
command reference linkUpdate
For even more control
*
can be replaced withls
.For example in a directory containing 1.txt, 2.txt, 3.txt, 1.jpg, 2.jpg and 3.jpg in order to filter only *.jpg files,
ls
can be used:The above code will assign to
a_file
variable all files with .jpg extension.Update added
-v
option tomv
command as per sds suggested.