Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

bash: execution of the processing workflow for the files defined in the array

I am working with the post-processing of the images located in the same folder "${vizu}"

# stack all images containet chicont keyword in the name
montage "${vizu}"/*chicont*.png -geometry 1200 -tile x"${rows}"e -mattecolor DarkGoldenrod2 -mode Frame "${vizu}"/${prot}_chimcont_rep${i}.png

Now I need to apply on some of the images pre-processing step in a selective manner:

convert "${vizu}"/${some_keyword}*chicont*.png -distort BarrelInverse 3:30 "${vizu}"/${some_keyword}_chimcont_DISTORTED.png

So basically the pipeline should be:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

# list of the pattersn occured somewhere in the filenames that should be considered for pre-processing using convert:

declare -A dataset=( 'some_keyword1' 'some_keyword2' 'some_keyword3')

..
if the name of the file match the pattern presented in dataset
or alternatively for every image mentioned in dataset..
do
convert .. 
done
:-)

and then stack all images (included post-processed and intacts) together using montage command. How could I make correctly the list of the keywords (part of the file names) that should be considered for the convert post-processing using either IF or FOR statements ?

>Solution :

Since you keywords are prefix and don’t seem to overlap, I would do a simple double loop.


for keyword in "${keywords[@]}"; do
  for file in "$vizu/$keyword"*chicont*.png; do
    convert $file something something
  done
done

You can even collect those files in another array if you need to collate them together after processing.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading