Modify DOS command.

bfuchs
bfuchs used Ask the Experts™
on
Hi Experts,

How can I modify this DOS command to only look at files created after a certain date?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Do you actually want to provide a date, or a number of days?


»bp
it doesn't matter which one you find easier to program.

Thanks,
Ben
Test your restores, not your backups...
Top Expert 2016
Commented:
At a  DOS command prompt try as below, adjust as needed.

(We shouldn't have needed the FOR /F loop around the FORFILES command, but FORFILES wraps the output @PATH in double quotes, and it turned out that FINDSTR was not happy at all with the list of files to be searched via it's /F option having those quotes...)

(for /f "tokens=*" %A in ('forfiles /s /p c:\temp /m *.php /d 07/01/2019 /c "cmd /c @echo.@path"') do @echo.%~A)|findstr /f:/ /i "0AB94000" > results.txt

Open in new window


»bp
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Thank you Bill, this works!!

Just one question (if not difficult...)

How do i include/exclude certain file names, for example

Z:\ftp\ENTOUT_613_SchChanges_20190805012112_FULL.csv

I would like to specify only files named "SchChanges", but not with wording "Full".

So this for example is a valid name for searching.

Z:\ftp\ENTOUT_613_SchChanges_20190805141511.csv

(in SQL for example I would write like '%SchChanges%' and not like '%FULL%')

Thanks,
Ben
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
It's not going to be doable in a practical sense.

You are only allowed one /M option, which specifies a typical DOS matching pattern to find files for.  So you could do something like:

/m *SchChanges*.*

to find all files with SchChanges in the name.  But there isn't an exclude option in FORFILES, and trying to do it in the CMD part of things would be difficult/impossible.


»bp
Hi Bill,

But there isn't an exclude option in FORFILES, and trying to do it in the CMD part of things would be difficult/impossible.
And how about excluding files over a certain size (which this may also work in this case, as FULL files are HUGE about a half gig while the rest are only small, usually not exceeding 5 MB).

Again, just asking if its doable, if yes then will post new Q.

Thanks,
Ben
Bill PrewTest your restores, not your backups...
Top Expert 2016
Commented:
You could try this to search only the files smaller than 100000 bytes in my example.  Didn't test it here though...

(for /f "tokens=*" %A in ('forfiles /s /p c:\temp /m *.php /d 07/01/2019 /c "cmd /c @if @fsize LSS 100000 @echo.@path"') do @echo.%~A)|findstr /f:/ /i "0AB94000" > results.txt

Open in new window


»bp
Thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial