Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.

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"

Which foldername for files modified in Feb, Mar, Apl etc...or were all 10k files modified only in Jan?

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.

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 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.&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...

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |