You are on page 1of 3

Copy Files According To Date Mdified

Tags: folder search command line batch


Score

0
Harneet Seistanis May 16, 2009 at 13:02:15 Pacific
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.
Reply Report Share on facebookShare on twitterShare on google_plusone Share on emailMore Sharing Services

Ads by Google

AD Group Membership Automate add/remove of Active Directory Members with policy. www.condreycorp.com/Groupsymmetry #1
Score

0
Chuck 2 May 16, 2009 at 13:22:55 Pacific 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"

Reply

Report

#2
Score

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

Reply

Report

#3
Score

0
Harneet Seistanis May 17, 2009 at 11:31:22 Pacific 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.

Reply

Report

#4
Score

0
Garibaldi May 18, 2009 at 00:43:25 Pacific Try this, it is untested... You must provide the path to the files in the Pushd command line.
:: Code begins... @echo off cls 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 :: :: Written date. :: Filename Filedate Dateday Files Name of a file extracted from the dir list. The Last Written date of the above file. The day of the file extracted from the Last 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.&echo.&echo.&echo. echo Total files copied = %files% popd exit /b :copyfile :: 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...

You might also like