How to find the oldest and newest files

Microsoft Windows server v2003 r2 standa...
March 3, 2010 at 03:02:49
Specs: Server 2003
I am trying to write a batch script that will find the oldest and newest date modified of the files in a folder. So if there were 7 files in a folder, 1 files for each day of a week, starting 22/02/2010 to 28/02/2010 I would want the script to create a folder called "22-02-2010 to 28-02-2010".

Is this possible?


See More: How to find the oldest and newest files

Report •

#1
March 3, 2010 at 04:31:25
As ever, much depends on the vcersion of DOS.


=====================================
Helping others achieve escape felicity

M2


Report •

#2
March 3, 2010 at 05:01:33
Sorry, the DOS version is 5.2.3790.

Report •

#3
March 3, 2010 at 06:57:48
Run this and post a few lines of the output.

------------------------
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
echo %%a %%~Ta
)


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
March 3, 2010 at 10:58:00
The result I get is:

C:\Test>test.bat
New Bitmap Image.bmp 03/03/2010 18:56 PM
New Rich Text Document.rtf 03/03/2010 18:56 PM
New Text Document.txt 03/03/2010 18:56 PM
New WinRAR archive.rar 03/03/2010 18:56 PM
test.bat 03/03/2010 18:55 PM


Report •

#5
March 3, 2010 at 12:45:33
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir /b/a-d/od') do (
set O=%%~Ta
goto :done old
)
:done old

for /f "tokens=* delims= " %%a in ('dir /b/a-d/o-d') do (
set N=%%~Ta
goto :done new
)
:done new

set O=!O:/=-!
set N=!N:/=-!

echo md "!O:~0,10! to !N:~0,10!


=====================================
Helping others achieve escape felicity

M2


Report •

#6
March 4, 2010 at 12:47:13
That works. Thanks for your help.

Report •

Ask Question