I have a zip file where each file is named the following


The files are actually jpegs How do I go about renaming them to the following?


closed as unclear what you're asking by Jeff Schaller, mosvy, Michael Homer, jimmij, Thomas Mar 9 at 9:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Wait, I completely missed an important word here; you have zip files that contain these filenames. Do you want to extract the zip file(s) to new filenames, or do you want to (end up with) renamed files inside the zip file? Or do you just have plain directories? – Jeff Schaller Mar 8 at 15:39
  • As the hint of the downarrow says: This question does not show any research effort. – Juan Mar 8 at 15:48

With prename (perl rename):

rename 's/original.jpg.(\d+).png/original$1.jpg/' original.jpg.*.png

I was able to accomplish this with the following bash script:


#Location of the zip file
#Desired location of extracted files

#Unzip the file to the desired location
unzip "$zip_file" -d "$dest_dir"

for f in "$dest_dir/"*.png; do
    #Remove path from filename.
    filename=$(basename "$f")
    #Remove .jpg. from filename.
    #Change .png to .jpg
    #Rename the extracted files to the preferred naming convention using mv.
    mv "$f" "${dest_dir}/${filename}"

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