Sponsored Content
Full Discussion: For loop sequence issue
Top Forums Shell Programming and Scripting For loop sequence issue Post 302438401 by rss0213 on Monday 19th of July 2010 02:21:52 PM
Old 07-19-2010
For loop sequence issue

Hi. I have a bunch of tif images in the directory with the following naming convention:

1.tif
2.tif
3.tif
.
.
.
n.tif

There are over 1000 tif images in this dir. I'm running a for loop to rename *.tif in this dir to <YYYYMMDD><NNNN>.tif, where YYYYMMDD is the current date (duh), and NNNN is a 4-digit sequence number beginning with 1 and incrementing with each tif image.

I also have an input csv file that references the images. I'm reformatting the csv file and including it in a zip file at the end of processing, which also contains the re-named zip files.

The problem I'm having is that the output csv matches the data in the input csv (and re-formatted properly), but the transactions in the output csv reference the wrong images.

I've discovered that the problem is in the For loop. This is the code:

Code:
cd $IMGPATH
   for file in $IMGPATH/*.tif ; do
      count=$((count + 1))
      count_str=$(printf "%04d" $count)
      mv $file $LBOX$DATEDIR$count_str"0.tif"
   done

The problem is that this sequences the files in the following order:

1.tif
10.tif
100.tif
1000.tif
etc

So my second transaction in the output csv file references the 10th image in the directory, the 3rd transaction in the csv file references the 100th image in the directory, and so on.

How do I make the loop sort by image number properly?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help With A For Loop Issue

I was wondering how I can modify this for loop, so it only loops through the filenames that do not have an ".old" extension. for filename in $(ls "$1") do echo $filename | grep '\.old$' > /dev/null if then mv $1/$filename $1/$filename.old fi done (5 Replies)
Discussion started by: ralts01
5 Replies

2. Shell Programming and Scripting

while loop issue

Hi, Following is my code and the file FILE_LIST_EXCESS.txt has 40 file names in it while read LineIn do echo ${LineIn} `ftp -vin << END_INPUT >> ${PID}_DS_GET_Log.log 2>&1 open servername user userid password cd FileDir get ${LineIn} END_INPUT`... (4 Replies)
Discussion started by: mgirinath
4 Replies

3. Shell Programming and Scripting

For Loop sequence question

I am using a for loop in a shell. My question is how does it list out the files in the example below. Does it list the files by name? How can I list the files by date so it will list the oldest file first in the sequence. Thanks! for f in /dir/*.* echo $f end (2 Replies)
Discussion started by: stringzz
2 Replies

4. Shell Programming and Scripting

loop issue

function ext { echo "THANKS & WELCOME BACK" } function upc { echo "TO EXPORT UPROC GIVE UPROC NAME PER LINE IN THE input.txt and PRESS Y" echo "TO GO BACK PRESS 99" read parm0 if ; then start elif ; then for i in `cat input.txt` ; do echo $i $UXEXE/uxext upr upr=$i... (0 Replies)
Discussion started by: kojo
0 Replies

5. Shell Programming and Scripting

until loop issue.

Hi, my script is waiting for 3 files to come to a folder for 30 min but even when all the files arrive in the folder it's still waiting for these three files. Files can come with in 2 min and I want it to start processing them immediately after all the files arrive in the folder. until ; do... (3 Replies)
Discussion started by: gurpartap
3 Replies

6. Shell Programming and Scripting

Issue with using While loop

Hi, I am trying to move a file from remote server to local server and when the transfer completes successfully i call a script in remote server to remove the file which was successfully transferred. I do this by first getting the list of file in remote server and move the text file to local... (8 Replies)
Discussion started by: funonnet
8 Replies

7. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

8. Shell Programming and Scripting

While Loop issue

Hi, i=0 t5=6000001 while do i=`expr $i + 1` t5=`expr $t5 + 1` echo $t5 done I am able to increment "col3" value but unable to get col1,col2 value. Input: t1=10001 t2=abc t3=ghkc (5 Replies)
Discussion started by: onesuri
5 Replies

9. Shell Programming and Scripting

Issue with for loop

Hi Team, I have for loop in my shell script. Which basically loop through all files in the directory, When some files are in the directory it works just fine. But if there are no files at all..still the for loop try to execute. Please help. Below is the code. #!/bin/ksh echo "Program... (5 Replies)
Discussion started by: bharath561989
5 Replies

10. UNIX for Beginners Questions & Answers

Issue when doing a loop

Hi, I just have started learning shell scripting (sh). Why do i only get the date? while read dt do echo "Date : ${dt} sed -n '/${dt}/,/${dt}/p' file1.log | grep -w ERROR done < date1.dat INPUT - date1.dat 2019-04-05 04:58:25 2019-04-05 04:58:26 2019-04-05 05:00:56... (3 Replies)
Discussion started by: margel
3 Replies
TIFFICC(1)						      General Commands Manual							TIFFICC(1)

NAME
tifficc - little cms ICC profile applier for TIFF. SYNOPSIS
tifficc [options] input.tif output.tif DESCRIPTION
lcms is a standalone CMM engine, which deals with the color management. It implements a fast transformation between ICC profiles. tifficc is little cms ICC profile applier for TIFF. OPTIONS
-a Handle channels > 4 as alpha. -b Black point compensation. -c <0,1,2,3> Precalculates transform. (0=Off, 1=Normal, 2=Hi-res, 3=LoRes) [defaults to 1] -e Embed destination profile. -g Marks out-of-gamut colors on softproof. -h <0,1,2> Show summary of options and examples. -i profile Input profile (defaults to sRGB). -k <0..400> Ink-limiting in % (CMYK only). -l Transform by device-link profile. -m <0,1,2,3> SoftProof intent. -n Ignore embedded profile on input. -p profile Soft proof profile. -o profile Output profile (defaults to sRGB). -q <0..100> Output JPEG quality. -t <0,1,2,3> Intent (0=Perceptual, 1=Colorimetric, 2=Saturation, 3=Absolute). -v Verbose. -w Wide output (generates 16 bps tiff). You can also use '*Lab' and '*XYZ' as predefined, built-in profiles for CIE L*a*b* and XYZ color spaces. EXAMPLES
To color correct from scanner to sRGB: tifficc -iscanner.icm in.tif out.tif To convert from monitor1 to monitor2: tifficc -imon1.icm -omon2.icm in.tif out.tif To make a CMYK separation: tifficc -oprinter.icm inrgb.tif outcmyk.tif To recover sRGB from a CMYK separation: tifficc -iprinter.icm incmyk.tif outrgb.tif To convert from CIELab TIFF to sRGB tifficc -iTiffLab8Spac.icm in.tif out.tif NOTES
For suggestions, comments, bug reports etc. send mail to info@littlecms.com. SEE ALSO
tiffdiff(1), jpegicc(1), icc2ps(1), icclink(1), icctrans(1), wtpt(1) AUTHOR
This manual page was written by Shiju p. Nair <shiju.p@gmail.com>, for the Debian project. September 30, 2004 TIFFICC(1)
All times are GMT -4. The time now is 10:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy