Question Locked

To Access file details in DOS

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to get the file created date and time and assign it to variables in DOS for all files in a folder .Is it possible ?Can somebody suggest a solution.
Thanks in advance
Sujish

3 replies

by cg it

if you know the path just do a CD [change directory] or do a dir at the command prompt [C:]

example c:\file name or c:\directory name\file name and the date the file was created would be listed.

by Member 25348569

For %i in (*.*) do set %i=%~ti

The above command will create a DOS environment variable using the filename as the variable's name with the variable's value set to the file date and time.

To use it from within a batch file,
For %%i in (*.*) do set %%i=%%~ti

The filespec can include the path but to avoid the variable name including the path, use
For %i in (c:\testit\*.*) do set %~nxi=%~ti

Typing Set , the output will be of the form

testfile.txt=05/04/2007 17:40

If you have a lot of files, you will run out of environment space PDQ.

Neil :)

Please, if you read this, tell me what you want to do...

This discussion is closed to new replies.