Search found 4316 matches
- 28 Dec 2011 08:48
- Forum: DOS Batch Forum
- Topic: infinite loop with break condition
- Replies: 75
- Views: 116188
Re: infinite loop with break condition
Was reading something over at Stack Overflow. This creates your infinite loop with a break but is also kills your batch file. Which would also be pointless. @echo off & setlocal EnableDelayedExpansion set /a num=0 for /L %%N in (1 0 10) do ( set /a num+=1 CALL :loop !num! ) :__loop () :loop IF &...
- 27 Dec 2011 12:31
- Forum: DOS Batch Forum
- Topic: delete 2 days older folders
- Replies: 18
- Views: 16991
Re: delete 2 days older folders
Posting a link to a script written on another forum by an old buddy of mine (TheOutcaste). m This script should work for you and it doesn't rely on what your DATE variable is. Credit is given throughout the script from whom wrote the original code. I can show you what lines you need to change for yo...
- 27 Dec 2011 11:57
- Forum: DOS Batch Forum
- Topic: delete 2 days older folders
- Replies: 18
- Views: 16991
Re: delete 2 days older folders
And squashman, that is what my script also doing, it is also keeping the two latest folders. But i want to keep other folders also which are not of month-date format. Regards, My script does not touch your XYZ or ABC folders. I pipe the output of the DIR command to the FINDSTR command. The findstr ...
- 27 Dec 2011 11:23
- Forum: DOS Batch Forum
- Topic: delete 2 days older folders
- Replies: 18
- Views: 16991
Re: delete 2 days older folders
And squashman, that is what my script also doing, it is also keeping the two latest folders. But i want to keep other folders also which are not of month-date format. Regards, My script does not touch your XYZ or ABC folders. I pipe the output of the DIR command to the FINDSTR command. The findstr ...
- 27 Dec 2011 06:48
- Forum: DOS Batch Forum
- Topic: delete 2 days older folders
- Replies: 18
- Views: 16991
Re: delete 2 days older folders
I should note that technically my script does not delete folders older than two days, it just keeps the two newest folders that match your date pattern. If you create a new folder every day for some type of backup this will essentially keep the two newest folders.
- 27 Dec 2011 06:37
- Forum: DOS Batch Forum
- Topic: delete 2 days older folders
- Replies: 18
- Views: 16991
Re: delete 2 days older folders
A batch file using the ForFiles command in combination with the findstr command may work better but ForFiles is not native to Windows XP. Going to throw my idea out there but I am sure other suggestions may come along that will work better as my script may have some caveats because I don't know how ...
- 26 Dec 2011 21:41
- Forum: DOS Batch Forum
- Topic: The final decider-Linux/Unix or Windows
- Replies: 8
- Views: 9509
Re: The final decider-Linux/Unix or Windows
One reason I joined this forum just a few days ago was because it is batch centric. I thought I knew a lot about batch scripting when I joined but now I am blown away by some of the tricks people do to get things done with batch scripts. I learn something new here every time I visit. I used to do a ...
- 24 Dec 2011 22:12
- Forum: DOS Batch Forum
- Topic: Piped input and output to a batch file
- Replies: 18
- Views: 22109
Re: Piped input and output to a batch file
That is pretty cool
- 24 Dec 2011 14:34
- Forum: DOS Batch Forum
- Topic: Can I get individual "unix" lines read by set /P "LN="
- Replies: 4
- Views: 4650
Re: Can I get individual "unix" lines read by set /P "LN="
Other option would be to run a UNIX2DOS command on the input file first. I have Win32 versions of several Unix commands on my pc just for situations like this. I knew about the set /p limitation with LF terminated text files. I have a batch file where I pull the first record from each file into anot...
- 23 Dec 2011 14:35
- Forum: DOS Batch Forum
- Topic: Piped input and output to a batch file
- Replies: 18
- Views: 22109
Re: Piped input and output to a batch file
Not understanding how you feel my response was incorrect.
You are not going to be able to use a PIPE to get the desired result he wants unless he would use something like SED or AWK. You would have to use a FOR Loop which is what I provided.
You are not going to be able to use a PIPE to get the desired result he wants unless he would use something like SED or AWK. You would have to use a FOR Loop which is what I provided.
- 23 Dec 2011 14:06
- Forum: DOS Batch Forum
- Topic: Piped input and output to a batch file
- Replies: 18
- Views: 22109
Re: Piped input and output to a batch file
You are not going to be able to do that without some type of stream editor like SED. They do make ports of it for Win32. But your examples shows that you want to do this from the output of the DIR command which is easy enough with a FOR LOOP. @echo off SETLOCAL set prefix=%~1 set suffix=%~2 FOR /F &...