How to open several image files from command line, consecutively, for editing?

As Rmano says, you can simply do a for loop in the terminal:

for i in 1.jpg 2.jpg 3.jpg; do gimp $i; done

Either run this in the directory where the files are, or each file should have the rest of the path to it. You can put as many files as you want in there.

GIMP will open the file, you edit it, and then close GIMP. Once GIMP closes, the for loop continues and opens the next file in the list.

If you don't want to close GIMP every time, you can try adding a read -p:

for i in 1.jpg 2.jpg 3.jpg; do gimp $i && read -p "Press [Enter] key to continue..."; done

Once you finish editing a file, you should be able to press Enter in the terminal and the next file should open in GIMP, without having to close GIMP.

This is the simplest way I could think of, it may get complicated trying to detect when GIMP closes a file.

Note for your case

Most of the files are SVG files, as Rmano pointed out. So list all of your SVG files and replace gimp with inkscape. The PNG files will be fine with gimp.


The following command opens the files in the default associated application:

edit 1.svg 2.svg 3.svg

If you want to open all the .svg files in alphabetical order, you can use the * wildcard:

edit *.svg

* stands for any sequence of characters, so you can use it in other ways; for example, to successively open the .svg files whose name contains wibble:

edit *wibble*.svg

Other wildcards exist if you want to select files based on finer-grained patterns.


You could try something like this:

shopt -s nullglob
for i in *
do
    if [ -d "$i"  ]
     then
        continue
    else
        inkscape "$i"

    fi
done

I tested it on my Pictures directory and it seemed to work.

I don't entirely understand the first line yet, but it is there to help make sure my * works. The for loop then loops through everything in the current directory one at a time. If it isn't a directory it opens it in Inkscape for editing.

When you're done editing and close inkscape the next image will open until there are no more images.


For your specific case (after reading the linked question) this might work better. Remember to cd to /usr/share/unity/icons and then run this:

for i in file1.svg file2.svg file3.svg
do
    if [ -d "$i"  ]
     then
        continue
    else
        inkscape "$i"

    fi
done  

replacing file1.svg file2.svg file3.svg with a list of the files you want to edit.