Search found 384 matches

by Samir
04 Nov 2015 21:16
Forum: DOS Batch Forum
Topic: Conditional Actions Using Data From Text File
Replies: 20
Views: 18124

Re: Conditional Actions Using Data From Text File

Something is not right. :(

Even with the original code, I'm not getting the right output for problems.txt. I'm not sure about sum since it truncates floating point numbers.

I'll see if I can't post some more details when I get some time. :(
by Samir
04 Nov 2015 13:12
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

Squashman wrote:
Samir wrote:When did this feature in dir come about? I know it wasn't there in the dos 6.0 days. Did it start in win95? Or was it with win2k or xp?

I would assume Windows NT.
I'll have to try it on my NT system. Thank you!
by Samir
04 Nov 2015 11:22
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

I checked the help on DIR and didn't see it, Well there is no concrete example showing it but the help file does use the plural of the word file. [drive:][path][filename] Specifies drive, directory, and/or files to list. I always thought of 'files' as just the normal list of files. When did this fe...
by Samir
04 Nov 2015 11:20
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

I'm a bit unsure, because of the question mark in "%%~a.%%~b?": When writing the code I was trying to use a dir command and filter the full list using the %currentdate% variable with findstr so the list is only retrieved once (a dir command with several masks execute several searchs, so I...
by Samir
04 Nov 2015 09:42
Forum: DOS Batch Forum
Topic: Conditional Actions Using Data From Text File
Replies: 20
Views: 18124

Re: Conditional Actions Using Data From Text File

It took me a bit to understand the algorithm in your code, but I think I got it now. I plan to use this code to get the filenames that are needed to be parsed: FOR /F "tokens=1-5" %a in ('dir bat*.rpt /a-d^|findstr /c:"%currentDate%"') do How would I incorporate this into the cod...
by Samir
03 Nov 2015 22:47
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

Squashman wrote:You can do multiple file masks with the DIR command.
I checked the help on DIR and didn't see it, but tried and you're absolutely right! Learned something big today! Thank you! I'll see how I can best incorporate this. Probably won't change speed, but definitely will make the code easier to read.
by Samir
03 Nov 2015 17:08
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

If you differ between the filetypes, then you probably could simplify to: FOR %%F IN (DAY PLU SKU ) DO for /f "tokens=1,2 eol=|" %%a in (' dir %%F*.rpt /a-d /-n /o-d ^| findstr /c:"%currentDate%" ') do set "%%~F=%%~a.%%~b" I'm a bit unsure, because of the question mark...
by Samir
03 Nov 2015 16:39
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

I've been able to tweak this even a bit more to make it execute almost instantly now. :REPORTSTART setlocal enableextensions enabledelayedexpansion FOR %%F IN (DAY PLU SKU) DO ( for /f "tokens=1,2 eol=|" %%a in (' dir %%F*.rpt /a-d /-n /o-d ^| findstr /c:"%currentDate%" ') do for...
by Samir
03 Nov 2015 15:07
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

If your system has short names enabled, then you could try this @echo off setlocal enableextensions enabledelayedexpansion set "currentdate=11/03/2015" for /f "tokens=1,2 eol=|" %%a in (' dir *.rpt /a-d /-n ^| findstr /c:"%currentdate%" ') do for %%c in ("%%~a.%%~...
by Samir
03 Nov 2015 14:59
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

I don't know if the following is much faster, but you could try to avoid using environment variables (instead this uses a tempfile; not tested): @echo off setlocal :: ... set current date ... >list.temp ( for %%f in ("DAY*.RPT" "PLU*.RPT" "SKU*.RPT" "*.txt") ...
by Samir
03 Nov 2015 14:25
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

I think the only way a singular loop might be faster is if it stopped working once all three files were found. You could jump out. SET "DAY="&SET "PLU="&SET "SKU=" FOR %%f IN (*.RPT) DO ( SET "filedatetime=%%~tf" SET "file=%%f" IF "!fil...
by Samir
03 Nov 2015 13:43
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

Kinda ironic when you're telling me about being 'behind' and we're essentially talking on a site about DOS batch files--an operating system that's been extinct now since windows 98. You are incorrect. We are not talking about DOS batch files. We are talking about Windows (NT) batch files which are ...
by Samir
03 Nov 2015 09:51
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

Thank you for the many solutions. I'll parse through them when I get a chance. Maybe Robocopy would be faster at finding them. On the systems where this executes, it's not installed. That was actually my first inclination. Or maybe outputting the directory to a file if that can be searched faster. U...
by Samir
02 Nov 2015 17:51
Forum: DOS Batch Forum
Topic: Optimizing These Loops
Replies: 31
Views: 31354

Re: Optimizing These Loops

Squashman wrote:Maybe Robocopy would be faster at finding them.
On the systems where this executes, it's not installed. :( That was actually my first inclination. Or maybe outputting the directory to a file if that can be searched faster.
by Samir
02 Nov 2015 17:46
Forum: DOS Batch Forum
Topic: Conditional Actions Using Data From Text File
Replies: 20
Views: 18124

Conditional Actions Using Data From Text File

I have several text files that on line 8 either have text that I can use in a conditional to execute something, or are blank, which indicates another action needs to be taken. What's a good methodology for this? Here's some example files to work with: FILE TYPE 1 ------------------------------------...