Tuesday, May 7, 2024
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 6662  / 2 Years ago, mon, may 30, 2022, 8:40:38

Lets say I have three image files to edit. Consider all the files are in ~/Pictures. Let name of the first file be 1.svg, name of the second file be 2.svg and name of the third file be 3.svg .I have Inkscape editor. Now, I want a bash script to be executed so that the following must happen:




  1. First 1.svg must open for me to edit.

  2. After editing, when I close that file, automatically 2.svg must open for me to edit.

  3. Now when I complete editing 2.svg, I want 3.svg to open for editing.

  4. Now after editing 3.svg the script must end by closing GIMP.



PS:- If you are wondering if this is home work, it is not! See here . You will notice that I have to edit images there. To make that answer better I need help here. So please help. Also I AM A COMPLETE BEGINNER. I don't know anything about bash. So explain your answer as elaborately as possible. Also you might consider giving an answer with GIMP editor to edit .jpg files . It might be useful for others. By the way, I am using 14.04 LTS . Thanks in advance.



UPDATE :- The above linked answer was edited according to the accepted answer below.


More From » command-line

 Answers
6

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.


[#25670] Tuesday, May 31, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dersol

Total Points: 78
Total Questions: 100
Total Answers: 124

Location: Christmas Island
Member since Mon, Oct 19, 2020
4 Years ago
;