bash - How to automate file transformation with simultanous execution? -


i working on transforming lot of image files (png) text files. have basic code 1 one, time consuming. process involves converting image files black , white format , using tesseract transform text file. process works great take days me acomplisyh task if done file file. here code:

for f in $1  echo "processing $f file..."  convert $f -resample 200 -colorspace gray ${f%.*}bw.png  echo "ocr'ing $f"  tesseract ${f.*}bw.png ${f%.*} -l tla -psm 6  echo "removing black , white $f"  rn ${f%.*}bw.png done echo "done!" 

is there way perform process each file @ same time, is, how able run process simultaneously instead of 1 one? goal reduce amount of time take me transform these images text files.

thanks in advance.

you make content loop function call function multiple times send each background execute another.

function my_process{     echo "processing $1 file..."     convert $1 -resample 200 -colorspace gray ${1%.*}bw.png     echo "ocr'ing $1"     tesseract ${1.*}bw.png ${1%.*} -l tla -psm 6     echo "removing black , white $1"     rn ${1%.*}bw.png }  file in ${files[@]}     # & @ end send background.     my_process "$file" & done 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -