| 1. |
Solve : Decypher file attribute in a FOR loop? |
|
Answer» My tests on the attribute variable seemed to work but I will give your suggestion a try. I am creating two dates in the format yyyyddd. I start by taking the year and multiplying by 1000 You may find these SCRIPTS useful http://www.commandline.co.uk/cmdfuncs/dandt/index.html Also, VBscript has built in date MATH functions. You can USE them from batch, if VBscripts are allowed on your system Code: [Select]@echo off REM Create VBscript echo wsh.echo Year(wscript.arguments(0))^&DatePart("y", wscript.arguments(0))>Daynumber.vbs REM now you can use it in your script as many times as you want set querydate1=20/11/2009 REM pass the date to the VBscript & get back the result for /f "delims==" %%D in ('cscript //nologo Daynumber.vbs %querydate1%') do set Daynumber1=%%D set querydate2=20/03/2009 for /f "delims==" %%D in ('cscript //nologo Daynumber.vbs %querydate2%') do set Daynumber2=%%D echo The day number of %querydate1% is %Daynumber1% echo The day number of %querydate2% is %Daynumber2% output Code: [Select]The day number of 20/11/2009 is 2009324 The day number of 20/03/2009 is 200979 As you can see, my system uses the European dd/mm/yyyy format for dates but I believe that if your system locale settings are US you would find that 11/19/2009 would give you 2009323 but you would have to try that yourself. Hello |
|