Home > Back-end >  bash: execution of the processing workflow for the files defined in the array
bash: execution of the processing workflow for the files defined in the array

Time:02-01

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:

# 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 ?

CodePudding user response:

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.

  •  Tags:  
  • bash
  • Related