|
Answer» Hi,
Hope someone can help me with this: having a bit of an issue trying to create a batch file for XP that INCREMENTS a number in a file named properties.p: the batchnumber will START from 100 and increment+1 everytime batch file is run. example of properties.p files CONTENTS:
# #Tue Jul 08 14:58:54 BST 2014 BatchNumber=100
Thanks in advance Kev
Code: [Select]# #Tue Jul 08 14:58:54 BST 2014 BatchNumber=100 Do you need the first two lines? Do they have to CHANGE at all?Hi,
Thanks for the reply, yes i will need the first two lines, the first two lines will remain the same, its just the third line that i will need to increment by 1,
thanksThis works here:
Code: [Select]echo off
<properties.p ( set /p a= set /p b= set /p c= )
for /f "tokens=1,* delims==" %%a in ("%c%") do set c=%%a&set d=%%b
set /a d=d+1
( echo %a% echo %b% echo %c%=%d% )>properties.p Excellent thanks very much that worked for me
now say if i have a LIST of files like below that are created already and will match the batch number: LR0100*.* LR0101*.* LR0102*.* LR0103*.* .... ....
how could I in a batch file copy one file at a time from a folder into another so that the next time i run the batch file it copies LR0101 and next time LR0102 and so on...
Hope I am clear Thanks a million
Explain a little more clearly.
When you click the batch file above, what do you want copied from where and to where? ok so in a folder c:\kevin\ i will have individual files named LR0100*.*, LR0101*.*, LR0102*.* and so on (could be 80 files) ... in the batch file i would like it to COPY LR0100*.* to c:\kevin\archive\ then using your previous script increment the batch number file + 1 and end the batch file. then when i run the batch file again this time it would copy LR0101*.* to c:\kevin\archive\ and increment the batch number file + 1, and so on.
EDIT: the files that i will have in C:\Kevin\ will be all the same filename except incremented by 1 like above for each file.This assumes that the folders already exist:
Code: [Select]echo off
<properties.p ( set /p a= set /p b= set /p c= )
for /f "tokens=1,* delims==" %%a in ("%c%") do set "c=%%a"&set "d=%%b"
copy "c:\kevin\LR0%d%*.*" "c:\kevin\archive\"
set /a d=d+1
( echo %a% echo %b% echo %c%=%d% )>properties.p
Excellent stuff that worked like a charm!!
thanks for all your help!
|