views:

34

answers:

2

how get the date and time of the last modified particular TYPE file in that directory

let me explain with an example

if i use the command dir *.reo /o:d

i get the all *.reo files in that directory sorted according to the date ..

this is the the last line of the output

29-03-2010 11.31 arun.reo

now i just want to copy the date and time of the last created file in variable or file .is it possible ?

A: 

It depends on what os your using. If you want just the last file

command one pipes the complete directory into a temp file

dir *.reo /o:d > temp.txt;

command two gets the last line of the temp file. Only works if you have the windowserver 2003 install which the link is provided below.

tail - 1 temp.txt;

Go to the Microsoft Windows Server 2003 download section at http://www.microsoft.com/windowsserver2003/ downloads/tools/default.mspx. Or, if that link does not work, visit http://www.microsoft.com/ and search for "Windows 2003". Once there, choose the "Downloads -> Tools" link.

george9170
is tail a ms-dos command?
Arunachalam
no it is a unix command, but downloading the microsoft toolkit in the link i provided will give you access to it.
george9170
+1  A: 

You can do this using a batch file like this:

@echo off
setlocal enableextensions

for /f "delims=" %%f in ('dir *.reo /o:-d /b') do (
  set dt=%%~tf
  goto endloop
)

: endloop
echo %dt%

A little explanation:

  • dir *.reo /o:-d /b produces a list of all .reo files in the current directory, sorted by date in descending order (so that the last modified file comes first).
  • %%~tf expands to the date of the file specified by the %f variable.
Helen
thank u and do u know how to append a empty line in text file for eg :echo hi >a.txtecho >>a.txtecho arun>>a.txtbut when doing this it prints echo on in the empty space what to do ?
Arunachalam
@Arunachalam: `echo.` outputs a blank line. To append it to a file, use `echo.>>file.txt`
Helen