I mean something like Code: if file.txt exist goto 1 else goto 2 :1 save.exe -file1.txt goto end :2 save.exe goto end :END but to make it "infinite".. I mean if file1.txt exist, save file2.txt, if file2.txt exist, save file3.txt This code above is just explain what I need to have, any help appreciated
What you need is a FOR-loop, see this post on the subject and see if you can adapt it for your own needs
Tried this but can't bring it to work It's always replace file1.txt Could You please give example how it should looks?
I think I understand, you want the script to save files numbered ascending, so that when you have already saved file1.txt and file2.txt, the next one should naturally be file3.txt. To be honest I am not sure how to do that in Batch. In for example C# or AutoIt3 I would've used Regular Expressions to match the file names of all the text files, identified the highest number and then continued the numbering. Here is an example of how you can loop just the files that are formatted as file[...].txt Code: @echo off for %%i in (file*.txt) do echo %%i pause I'll get back to you if I come up with a solution, meanwhile maybe one of the Batch gurus will step in?
This might do what you want (minimally tested) Code: (SET "FILECNT=") GOTO TESTCOUNT :INCFILECOUNT (SET /A FILECNT=%FILECNT%+1) :TESTCOUNT IF EXIST file%FILECNT%.txt GOTO INCFILECOUNT save.exe file%FILECNT%.txt REM or whatever you need to do with the file If you embed this in a loop or a subroutine you might need to change %FILECNT% to !FILECNT! Cheers and Regards
To not make a mess I ask here.. How to make my script read from .ini (or whatever else wchich could be edited in notepad) and place it content somewhere in my script For example, I have ini file with content of "/type:ANSI" and want to be placed "save.exe there file%FILECNT%.txt"