Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Move files recursively from source to destination that are older than 15 days  (Read 4264 times)

0 Members and 1 Guest are viewing this topic.

nirasmar

  • Guest
Hi -

I have a  requirement to move files from source location(recursively) to destination(mapped drive) that are older than 15 days from current date


folder structure in both source and destinatin is similar

Please help

marvinengland



    Hopeful

    Thanked: 11

    I have a  requirement to move files from source location(recursively) to destination(mapped drive) that are older than 15 days from current date



    The following code is only a start. I have tried to list the files that are older than 15 days with the forfiles command.

    The code needs a lot of work but might help to get you started.

    Good Luck
    _______________________________________ __


    C:\test>type  mira.bat
    Code: [Select]
    @echo off

    FORFILES /D -15 /M *.* > old15.txt

    echo.  >  old15days.txt

    for /f "delims=" %%i in (old15.txt) do echo %%~i >> old15days.txt

    for /f "delims=" %%i in (old15days.txt) do echo %%i

    Output:


    C:\test>mira.bat
    buildlog.bat
    chtoE.bat
    cmpfil.bat
    cmplist.bat
    evaluate.vbs
    fil.bat
    helpme.bat
    matt.bat
    matt2.bat
    matt3.bat
    matt4.bat
    matt5.bat
    ver6.txt
    ver61.bat
    ver612.bat
    x.bat
    yesterday.bat

    C:\test> type  count.txt
    03/04/2009  12:26 PM                41 evaluate.vbs
    01/01/2010  11:33 AM               187 yesterday.bat
    04/24/2010  02:39 PM             1,018 buildlog.bat
    04/24/2010  02:39 PM             1,018 x.bat
    04/24/2010  06:37 PM               199 matt.bat
    04/25/2010  11:27 AM               260 matt2.bat
    04/25/2010  11:27 AM               260 matt5.bat
    04/25/2010  11:34 AM               307 matt3.bat
    04/25/2010  11:41 AM               224 matt4.bat
    04/25/2010  02:07 PM                38 ver6.txt
    04/25/2010  02:17 PM               125 ver61.bat
    04/25/2010  02:33 PM               190 ver612.bat
    04/25/2010  05:14 PM               235 helpme.bat
    04/27/2010  12:06 PM                32 chtoE.bat
    04/27/2010  07:33 PM                89 fil.bat
    04/27/2010  09:52 PM               631 cmpfil.bat
    04/27/2010  10:18 PM               698 cmplist.bat
    C:\test>
    USA