[<<]Message[>>]    [<<]Author[>>]    [<<]Subject[>>]    [<<]Thread[>>]

Number : 1122 Date : 2001-12-07 Author : Garry Deane Subject : Re: Move Directory Based On Modified Date Size(KB) : 2
Xxcopy won't do this as it is file oriented not directory oriented. You can do it with a batch file based on a FOR loop and the output from a 'dir /o:d /a:d /n' command. You then extract the directory's date and do a date comparison with today's date using a batch file created by Jerry Schulman called JSIDateM which is available at http://www.jsiinc.com/SUBB/tip0700/rh0721.htm Following is a generic DOS (NT or higher) based 'days old' batch file which does the sort of thing you want. This is a bit more complex than you might need as it handles various date formats. Obviously, once you know how old the directory is, you then carry out a MOVE or XXCOPY using the directory name. @echo off :: ------------------------------------------------------------------ :: Calculate the number of days ago that a directory was created. :: Only examines sub-directories of the current directory or sub- :: directories of the directory passed as a parameter. :: Only uses the file's date (not time) and relies on Jerry Schulman's :: JSIDateM routines to calculate the date difference. :: ------------------------------------------------------------------ setlocal :: Use date to determine the date format e.g. dd-mm-yy, mm-dd-yy, etc for /f "tokens=2 skip=1 delims=()" %%a in ('echo.^|date') do set datefmt=%%a :: Now get today's date and split it into dd,mm,yyyy based on datefmt for /f "tokens=2" %%a in ('date /t') do set today=%%a if %datefmt%==dd-mm-yy (set tdd=%today:~0,2%& set tmm=%today:~3,2%& set tyy=%today:~6,4%) if %datefmt%==mm-dd-yy (set tmm=%today:~0,2%& set tdd=%today:~3,2%& set tyy=%today:~6,4%) if %datefmt%==yy-mm-dd (set tyy=%today:~0,4%& set tmm=%today:~5,2%& set tdd=%today:~8,2%) :: Extract the file date & name from the directory listing for /f "tokens=1-3,* skip=5" %%a in ('dir %1 /o:d /a:d /n ^| find "" ^| find /v "."') do call :check_age %%a "%%d" endlocal goto :eof :check_age set fdate=%1 :: Split the file's date into dd,mm,yy based on datefmt if %datefmt%==dd-mm-yy (set fdd=%fdate:~0,2%& set fmm=%fdate:~3,2%& set fyy=%fdate:~6,2%) if %datefmt%==mm-dd-yy (set fmm=%fdate:~0,2%& set fdd=%fdate:~3,2%& set fyy=%fdate:~6,2%) if %datefmt%==yy-mm-dd (set fyy=%fdate:~0,2%& set fmm=%fdate:~3,2%& set fdd=%fdate:~6,2%) :: Add 19 or 20 to get yyyy if %fyy% GTR 80 (set fyy=19%fyy%) else (set fyy=20%fyy%) :: Call JSIDateM to calculate the date difference. Format is yyyy1 mm1 dd1 - yyyy2 mm2 dd2 :: JSIDateM sets %ndd% to indicate date difference call JSIDateM %tyy% %tmm% %tdd% - %fyy% %fmm% %fdd% echo %2 is %ndd% days old goto :eof --- In xxcopy@y..., "shaynekolata" wrote: > Can XXCOPY move directories from one drive to another based on the > modification or creation date of a directory?
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.