Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
9/18/2013 11:11:56 AM EDT
OK gents, I am completely freaking stuck on something any first year IT student should be able to do, but I'm a little scatterbrained today as we found out my Mom has a small mass on her brain via some MRI results last night.

Here goes:
I know how to do this based upon either of the criteria by itself, but Im not sure how to use them in conjunction.
I have an FTP folder where a vendor uploads some reports every night. I need to create a script that will select the most recently created report whose file name begins with "CustomExports_2" (the rest of the filename is a system generated time/date stamp).

I know to do a partial name match, you can do this "%CustomExports_2%" as the selector, but this would return several dozen files.

I know to do the date, you could use a token like this:
for /f "tokens="" %%a in ('dir /b /od *.csv 2^>NUL') do set lastmod=%%a
But that wouldn't filter out the other custom reports (i.e CustomExports_1).

How do I do these together, and make it poop out a file named "Output.csv"?
9/18/2013 11:29:15 AM EDT
[#1]
Nice guy over on Tom's Hardware hooked me up. Here's the script in case this helps anyone else:
::====== script starts here ===============
::
:: cust.bat 2013-09-19 2:06:42.59
@echo off > Output.csv & setLocal enableDELAYedeXpansioN
for /f "tokens=* delims= " %%a in ('dir/b/o-d CustomExports_2*') do (
set outfile=%%a
goto :done
)
:done
echo !outfile!
goto :eof
::====== script ends here =================
View Quote