-3

Currently I have a script that can run only in a single folder.

#!/bin/bash
for file in ls -1 *.jpg|sort -t . -n -k 3
do
  echo "compute ./scripName $file"
  ./scriptName $file
done 

Question: I have a several folders containing *.jpg images. I need a script that can over all images of all folders.

1 Answers1

0

you can use a nested for loop,

for f in folder1 folder2 folder3; 
do
   cd $f
   for file in ls -1 *.jpg|sort -t . -n -k 3
   do
      echo "compute ./scripName $file"
      ./scriptName $file
   done  
done

*Please note that this is not a foolproof script and in this case folder1,folder2... have to be a full paths to make this script to work.

Rabin
  • 3,883
  • 1
  • 22
  • 23
  • Thanks! I m wondering if we can make it for N folders, where we can avoid user input. can we? – Santosee Aug 06 '14 at 22:45
  • It depend who the folders are spread and if they have something in common (some search criteria). – Rabin Aug 07 '14 at 07:38