|
Answer» I need to obtain the modifed date of a FILE as a parameter in a batch file.
I would USE this later to append to the filename when I move it.This would thus give it a unique file name.
could someone help me out!
eg :file: bo_trigger_0030.txt modified date : 07/15/2005 15:34:55
I would like to obtain this 20050715_153455_bo_trigger_0030.txt
This is messy and a windows script would've been a better choice but this may give you some ideas:
Code: [Select] for /f "skip=5 tokens=1-8 delims=/: " %%a in ('dir /tc bo_trigger_0030.txt') do ( SET mon=%%a set day=%%b set yyyy=%%c set hh=%%d set min=%%e set filename=%%h goto label ) :label echo %mon% %day% %yyyy% %hh% %min% %filename%
Once you have the variables you can do anything you need to.
Note: The code on the dir can be: /tc - date created /ta - date accessed /tw - date written
Hope this helps.
Thanks a lot for the lead.. I modified the echo COMMAND as below to remove the spaces in the output.
echo %mon%%day:~0,2%%yyyy:~0,4%%hh:~0,2%%min:~0,3%%filename% (must be CAKEWALK for you but for others like me )
the output is: 071520050300pbo_trigger_0030.txt
Regards, Aamir
|