Using the While Statement

Started by mtruong1, October 30, 2013, 09:34:20 AM

Previous topic - Next topic

mtruong1

I have many files (ie, don.mig, dan.mig, jon.mig, etc.) in a folder name "migrate".
I want to process each file and then rename each of file (ie, don.mig = don.mig.done) until all the files with the .img extension is done in this folder
I am think of using the While statement but not sure of the syntax.  In another words, what is the syntax for the statement

While existing *.mig file
process1
process2
rename file
endwhile

Please help

Deana

The function you are looking for is FileItemize or FileItemPath. Here is an example that uses FileItemize:

Code (winbatch) Select

dir = "C:\TEMP\"; or use DirScript() for the current working directory of the script.
DirChange( dir ) ; Important:  must change the working directory to root dir.
filelist = FileItemize('*.mig') ; Returns a tab delimited list of all file names matching the wildcard.
For i = 1 to ItemCount(filelist, @tab) ; Iterate thru tab delimited list
   filename = ItemExtract( i, filelist, @tab ) ; Extract th items in order
   newfilename = filename:'.done'
   FileRename( filename, newfilename ) ; Rename the file
Next
Exit
Deana F.
Technical Support
Wilson WindowWare Inc.

mtruong1

That works !!!
but, the newfilename = filename:'.done' posting an error message 3074: Expression continues past expected end.

I am using winbatch 32 2002B.

any ideas??

mtruong1

Deana

That older version doesn't support the colon concatenation operator. you will need to use StrCat instead:

Code (winbatch) Select
newfilename = StrCat( filename, '.done' )
Deana F.
Technical Support
Wilson WindowWare Inc.