Computing.Net > Forums > Windows XP > Copy files according to Date Mdified

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Copy files according to Date Mdified

Reply to Message Icon

Name: Harneet Seistani (by Harneet Seistanis)
Date: May 16, 2009 at 13:02:15 Pacific
OS: Microsoft Windows XP Professional
CPU/Ram: 1.995 GHz / 1527 MB
Subcategory: Configurations
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Chuck 2
Date: May 16, 2009 at 13:22:55 Pacific
Reply:

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"


0

Response Number 2
Name: Valerie (by Garibaldi)
Date: May 16, 2009 at 18:29:00 Pacific
Reply:

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


0

Response Number 3
Name: Harneet Seistani (by Harneet Seistanis)
Date: May 17, 2009 at 11:31:22 Pacific
Reply:

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.


0

Response Number 4
Name: Valerie (by Garibaldi)
Date: May 18, 2009 at 00:43:25 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Copy files according to Date Mdified

Copy files with original date/time www.computing.net/answers/windows-xp/copy-files-with-original-datetime/144717.html

copying files 98 to xp www.computing.net/answers/windows-xp/copying-files-98-to-xp/151870.html

Batch File that adds Date www.computing.net/answers/windows-xp/batch-file-that-adds-date-/130663.html