Copy files according to Date Mdified

May 16, 2009 at 13:02:15
Specs: Microsoft Windows XP Professional, 1.995 GHz / 1527 MB
I have close to 10,000 files in one parent folder. Need to copy the files depending on the date they were modified. e.g. Files modified on Jan 1 2009 only to folder c:\1, files modified on Jan 2 2009 only to folder c:\2, etc.
Need a batch file to do so. please help.

See More: Copy files according to Date Mdified

Report •

May 16, 2009 at 13:22:55
You could do ---
Select folder the files are in,
click Search,
click "files and folders,
then click "When was it Modified",
then set your date,
then copy the files in the "Search Result"

Report •

May 16, 2009 at 18:29:00
Which foldername for files modified in Feb, Mar, Apl etc...or were all 10k files modified only in Jan?

Report •

May 17, 2009 at 11:31:22
All files have been modified in Jan but on diffrent dates at diffrent time, want to copy files for one date to one folder.

Chuck2: Thanks for the help but need sctipt or batch files to do the work.

Report •

Related Solutions

May 18, 2009 at 00:43:25
Try this, it is untested...

You must provide the path to the files in the Pushd command line.

:: Code begins...
@echo off
setlocal enabledelayedexpansion

:: The only validity checking is that the month = 01 (Jan)
:: The year is not checked.....

set files=
set dateday=
set filedate=
set dateday=

:: Variables are  Filename   Name of a file extracted from the dir list.
::                Filedate   The Last Written date of the above file.
::                Dateday    The day of the file extracted from the Last Written date.
::                Files      The number of files copied.

:: The date in the directory listing must be in the format mm/dd/yyyy

:: Set default directory to location of files......
pushd path\to\files\

:: Create directory listing & set Filename and Filedate vars...
for /f "delims=" %%1 in ('dir /a-d /tw /od /b') do (
    set filename=%%1
    set filedate=%%~t1 & call :copyfile


echo                  Total files copied = %files%
exit /b

:: Check if month = 01........
if %filedate:~0,2% equ 01 (
   set dateday=!filedate:~3,2!
   ) else (
   goto :eof

:: Reduce date to one digit if date <10..........
if %dateday% lss 10 set dateday=!dateday:~1,1!

:: Check if output directory exists, if not create it..........
if not exist C:\!dateday! md c:\!dateday!

:: Copy file created in January to output directory
copy "!filename!" %temp%trial\!dateday!\ > nul
set /a files+=1

goto :eof

:: Code ends...

Report •

Ask Question