uom0
uom0

Reputation: 383

Bash script image processing with im2dcm

I have a tool in Linux called img2dcm to convert from jpg to DICOM (dcm) format as follows: img2dcm image-001.jpg image-001.dcm (I've already tried to do use a python based script but it doesn't works...)

I have 100 images and doing it by hand would be a nightmare...

I'm wondering if is possible to do a Bash script with a for loop i:1:100 to convert each image-i.jpg ? (notice that the couldn't be image-1 should be image image-001, 002...010..020..099 until 100...).

Thank you very much in advance... .

Upvotes: 0

Views: 863

Answers (2)

uom0
uom0

Reputation: 383

Thank you very much for your soon response! I also fixed it with this... So no matters the number of files :)... .

!/bin/bash

    for i in $( ls ); do
        a=${i%%.*}
    
    echo $a.jpg
    img2dcm $a.jpg $a.dcm
    done 

Thank you again!.

Upvotes: 1

meuh
meuh

Reputation: 12255

Here's an example:

for i in {1..100}
do j=$(printf "%03d" $i)
   img2dcm image-$j.jpg image-$j.dcm
done

Upvotes: 4

Related Questions