1

I have a list of JPG files, each located in different folders on my command line only server, that I need converted to PNG.

I know the simple command to convert them one-by-one using mogrify. But I have around 300 images of different names spread across all different folders like so:

/home/user/dfp/app/roundtable/wp-content/uploads/2022/06/play.jpg
/home/user/dfp/app/roundtable/wp-content/uploads/2021/02/turn.jpg
/home/user/dfp/app/roundtable/wp-content/uploads/2020/01/up.jpg
/home/user/dfp/app/roundtable/wp-content/uploads/2022/09/down.jpg
/home/user/dfp/app/roundtable/wp-content/uploads/2021/01/left.jpg
etc etc

There is thousands of other images in each of the directories too, that I don't want altered at all. Just the specific files in my list.

Is there an easy watch to batch / bulk convert the list of images I have? I literally have a list of the images, like the example above, in a .txt file.

1 Answer 1

1

You can use a simple shell loop to read and process the filenames from the list file. In a bash shell for example:

while IFS= read -r file; do
  # your mogrify command on "$file"
done < path/to/listfile.txt

You can run it either in the interactive bash command line, or as a script with the #!/bin/bash shebang at the top.

2
  • Thanks, are those 3 separate commands I run in shell, or so I put those into a .sh file and run that? Please respond like I am a 5 year old.
    – Matt
    Commented Nov 16, 2022 at 2:42
  • 1
    @Matt you can do either - see edit Commented Nov 16, 2022 at 15:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .