schinni
asked on
Regarding Windows/Dos scripting in WIN2K
Hello,
I have some files in this format
testss_db_200312041101.BAK
ts_db_200312030901.bak
abcsscscscs_db_20031203070 7.BAK
Is there a way i can write a script to go through all the files in a particular directory
and get that datetime part (200312041101)
Thanks in Advance.
I have some files in this format
testss_db_200312041101.BAK
ts_db_200312030901.bak
abcsscscscs_db_20031203070
Is there a way i can write a script to go through all the files in a particular directory
and get that datetime part (200312041101)
Thanks in Advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can you help me with this
Hello,
I have to delete files older than 3days
My files end with this extension 2000402021211..etc
so i am getting the extension and comparing with
currentdate -3
basically i want to do %FileDD%/ -3
rem @echo off
setlocal
for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
for /f "tokens=5-8 delims=:., " %%a in ('echo:^|time') do (
set hh=%%a
set mn=%%b
set ss=%%c
set cs=%%d
)
set curtim=%d:~6,4%%d:~0,2%%d:
:: Current Date -3
I am doing this because of octal 8 and 9
if %d:~3,2% LSS 10 set /a dat = %d:~4,1%-3
if %d:~3,2% GTR 7 set /a dat = %d:~4,1%-3
if %d:~3,2% GTR 09 set /a dat = %d:~3,2%-3
if %d:~3,2% LSS 8 set /a dat = %d:~3,2%-3
if %dat% LSS 10 set dat=0%dat%
if %hh% LSS 10 set hh=0%hh%
set timestr=%d:~6,4%%d:~0,2%%d
I am doing this to getting the currentdate and subtracting date varaible with -3
it works great but when it's from day 1 to 3 of the month i am getting negative variables
and also one more thing is
cuurent date is 200402021111 i am subtracting 02 -3 which i am getting -1
and the whole doesn't work correctly ..
can anybody help me with the workaround
Thanks in Advance!