How to get file date and display on screen?

August 9, 2010 at 17:04:02
Specs: Windows XP
In batch file, how can I get the date of a modified MSAccess file and display it on screen like: "The file you are about to process is dated [date], is this correct?"

Thanks.


See More: How to get file date and display on screen?

Report •


#1
August 10, 2010 at 15:45:44
Is this any help?

@echo off 
cls
setlocal enabledelayedexpansion  

for /f "tokens=*" %%1 in ('dir /b /tw filename.mdb') do (
    set datime=%%~t1&set filedate=!datime:~0,10!
)

echo.&echo.
set /p answer=The file you are about to process is dated %filedate%, ^
is this correct? [Y/N] 

:: Script commands to process response go here.


Report •

#2
August 11, 2010 at 18:37:43
Thanks but this is what I get:

"The file you are about to process is dated ~0,10, is this correct? [Y/N]"

What is "~0,10" ?

Fyi, the file is dated 2010-04-30 (for this trial).


Report •

#3
August 11, 2010 at 19:57:26
Quote=jmrolls
"The file you are about to process is dated ~0,10, is this correct? [Y/N]"

The only time I can almost replicate the quoted display is if Delayed Expansion is not enabled as in line 3 of my script but I get "The file you are about to process is dated !datime:~0,10!, is this correct? [Y/N]".

Please check that enabledelayedexpansion has not been omitted in the script you are running.


Report •

Related Solutions

#4
August 12, 2010 at 17:26:37
I think I am having trouble with the file path. If my file is located here:

K:\Big Folder\Small Folder\New Folder\filename.mdb

How should I place that in the script?

Thanks


Report •

#5
August 12, 2010 at 20:22:58
Try this (not tested):

@echo off 
cls
setlocal enabledelayedexpansion

pushd K:\Big Folder\Small Folder\New Folder\

for /f "tokens=*" %%1 in ('dir /b /tw filename.mdb') do (
    set datime=%%~t1&set filedate=!datime:~0,10!

)
popd

echo.&echo.
set /p answer=The file you are about to process is dated %filedate%, ^
is this correct? [Y/N] 


Edited: Original response deleted.


Report •

#6
August 13, 2010 at 01:22:15
It worked! Thanks a lot!

Report •


Ask Question