I have scan several file and want to apply the imagemagick convert -rotate command , with a script , but only on file with a odd number .
Each name file contain a number from 1 to 24 , when I do an ls on the directory it doesn't seem to respect the normal number sequence (1,2,3,4,5,...) , here is what it give me :
Code:
gnu@robby:~/Documents/tp/Documents$ ls | grep dotrine.dr.etranger.tp- | nl
1 dotrine.dr.etranger.tp-10.jpg
2 dotrine.dr.etranger.tp-11.jpg
3 dotrine.dr.etranger.tp-12.jpg
4 dotrine.dr.etranger.tp-13.jpg
5 dotrine.dr.etranger.tp-14.jpg
6 dotrine.dr.etranger.tp-15.jpg
7 dotrine.dr.etranger.tp-16.jpg
8 dotrine.dr.etranger.tp-17.jpg
9 dotrine.dr.etranger.tp-18.jpg
10 dotrine.dr.etranger.tp-19.jpg
11 dotrine.dr.etranger.tp-1.jpg
12 dotrine.dr.etranger.tp-20.jpg
13 dotrine.dr.etranger.tp-21.jpg
14 dotrine.dr.etranger.tp-22.jpg
15 dotrine.dr.etranger.tp-23.jpg
16 dotrine.dr.etranger.tp-24.jpg
17 dotrine.dr.etranger.tp-2.jpg
18 dotrine.dr.etranger.tp-3.jpg
19 dotrine.dr.etranger.tp-4.jpg
20 dotrine.dr.etranger.tp-5.jpg
21 dotrine.dr.etranger.tp-6.jpg
22 dotrine.dr.etranger.tp-7.jpg
23 dotrine.dr.etranger.tp-8.jpg
24 dotrine.dr.etranger.tp-9.jpg
It seems ls classify the file according a kind of version number like 1.0 , 1.1 , 1.3 instead of 1,2,3.... 13,14,15 ......
About the script , I thought something like this
Code:
#!/bin/bash
for i in `ls | grep dotrine.dr.etranger.tp- | nl `
do convert -rotate 90
done
but how can grep the odd number in file name ?
Also can someone explain me why the normal number sequence isn't respected ? (it 's not the first time i saw that )
thank you
