How to create folder from find results

September 17, 2010 at 09:38:03
Specs: Windows XP
I have a sql query that finds the date of Friday for the current week and appends that date to Friday_ ...then outputs the results into a text file (G:\friday.txt)
contents of that text file:


I then inserted that sql query into a batch file I'm working on using osql
My question is how do I get the results into a variable in my batch file?

Friday_20100917 is located on the third line of friday.txt
Once I get this into a variable I want to use that variable to create a folder (G:\Testing\Friday_20100917)

Thanx in advance for any help

See More: How to create folder from find results

Report •

September 17, 2010 at 17:21:11
in batch, you can't live without the for loop. for /?

GNU win32 packages | Gawk

Report •

September 17, 2010 at 17:54:15
I actually solved this by using the following...
The sqlcmd calls the following sql query:
set nocount on
select ltrim('Friday_' + convert(char(8),dateadd(dd, 6-datepart (dw,getdate()),getdate()),112))

which then outputs the text "Friday_20100917" or whatever date friday ends up on when the query executes and outputs it to G:\friday.txt.

sqlcmd -E -S PROD1 -d MyDB -i G:\createfridayfolder.sql -o G:\friday.txt -n -h-1

set /p FolderName=<G:\friday.txt
mkdir \\corpprod1\Shared\Bits\OPPSGEN\ACS\ReportRunner\%FolderName%

Report •
Related Solutions

Ask Question