Need to copy files based on documents over 90 days from one location to
another on a different server \\shared path

Once this is complete. and The files have been copied/moved

I need to remove the files from the orginal location.

Re: copy/move delete help on files over 90 days = needs checked monthl by dNagel

dNagel
Mon Sep 10 09:18:52 PDT 2007



Rob wrote:
> Need to copy files based on documents over 90 days from one location to
> another on a different server \\shared path
>
> Once this is complete. and The files have been copied/moved
>
> I need to remove the files from the orginal location.
>
>
>
>
heres an example in VBS... ( Neither of these perform the copy, but it
seems easy
enough to modify either to do a copy before the delete. )

D.


Dim strPath = "C:\Temp\"
Dim iDays = 90

Set objFolder = objFSO.GetFolder(strPath)
For Each objItem In objFolder.Files
If objItem.DateLastModified < date() - iDays then
objFSO.DeleteFile(strPath & objitem.Name)
End If
Next



heres a post from experts exchange...

It's all in DOS batch, but it appears at a glance to do what you want.

D.


:: --------DELOLD.BAT----------
@echo off
SET OLDERTHAN=%1
IF NOT DEFINED OLDERTHAN GOTO SYNTAX

set FileDir=%~2

if "%FileDir%"=="" set FileDir=.

for /f "tokens=2" %%i in ('date /t') do set thedate=%%i

set mm=%thedate:~0,2%
set dd=%thedate:~3,2%
set yyyy=%thedate:~6,4%

set /A dd=%dd% - %OLDERTHAN%
set /A mm=%mm% + 0

:LOOPDATE

if /I %dd% GTR 0 goto DONE
set /A mm=%mm% - 1
if /I %mm% GTR 0 goto ADJUSTDAY
set /A mm=12
set /A yyyy=%yyyy% - 1

:ADJUSTDAY
if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
if %mm%==12 goto SET31

:SET31
set /A dd=31 + %dd%
goto LOOPDATE

:SET30
set /A dd=30 + %dd%
goto LOOPDATE

:LEAPCHK
set /A tt=%yyyy% %% 4
if not %tt%==0 goto SET28
set /A tt=%yyyy% %% 100
if not %tt%==0 goto SET29
set /A tt=%yyyy% %% 400
if %tt%==0 goto SET29

:SET28
set /A dd=28 + %dd%
goto LOOPDATE

:SET29
set /A dd=29 + %dd%

:DONE
if /i %dd% LSS 10 set dd=0%dd%
if /I %mm% LSS 10 set mm=0%mm%
for %%i in (%FileDir%\*.*) do (
set FileName=%%i
call :PROCESSFILE %%~ti
)

set mm=
set yyyy=
set dd=
set thedate=
goto EXIT

:SYNTAX
ECHO.
ECHO USAGE:
ECHO DELOLD X [Dir]
ECHO Where:
echo X is the number of days previous to Today.
echo Dir is the optional directory where files exist. Defaults to
current directory.
ECHO.
ECHO EX: "DELOLD 5" Deletes files older than 5 days.
echo "DELOLD 120 c:\temp Deletes files from the c:\temp directory
that are older
echo than 120 days.
GOTO EXIT

:PROCESSFILE
set temp=%1

set fyyyy=%temp:~6%

if /I %fyyyy% LSS 100 set fyyyy=20%fyyyy%
if /I %fyyyy% GTR 2069 set fyyyy=19%temp:~6%

set fmm=%temp:~0,2%
set fdd=%temp:~3,2%

:: +*************************************+
:: | This is where the files are deleted |
:: | Change the ECHO command to DEL to |
:: | delete. ECHO is used for test. |
:: +*************************************+

if /I %yyyy%/%mm%/%dd% GEQ %fyyyy%/%fmm%/%fdd% (
ECHO %FileName%
)

set temp=
set fyyyy=
set fmm=
set fdd=

:EXIT

:: ----------END-DELOLD.BAT-------------


Re: copy/move delete help on files over 90 days = needs checked monthl by Michael

Michael
Mon Sep 10 23:12:22 PDT 2007

On Mon, 10 Sep 2007 08:56:02 -0700, Rob wrote in
microsoft.public.scripting.vbscript:

>Need to copy files based on documents over 90 days from one location to
>another on a different server \\shared path
>
>Once this is complete. and The files have been copied/moved
>
>I need to remove the files from the orginal location.

Have you tried using FORFILES.EXE or ROBOCOPY.EXE?

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"