Batch script for win2000 that moves files

Hello,
I have never written any batch files before but I need to move files which are older than 2 days from one directory to another on a windows 2000 server. Can anyone help me out with that?
THanks,
Dee
indacryptAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sirbountyCommented:
This should do it - if you're looking for a vbscript method...


Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOutputFile:Set objOutputFile = objFSO.CreateTextFile("C:\FilesMoved.log")
Dim dtOld
strSourceFolder = "C:\Testing\"
strTargetFolder = "C:\TargetFolder\"
With objOutputFile
  .WriteLine "==========================="
  .WriteLine "Relocation summary for " & Date
  .WriteLine "=-=-=-=-=-=-=-=-=-=-=-=-=-="
  .WriteLine
End With

'intDel is the number of days old you want to check for.
intDel = 2
dtOld = DateAdd("d", -intDel, Date)

ProcessFolder objFSO.GetFolder(strSourceFolder)

With objOutputFile
  .WriteLine
  .WriteLine "Process completed at " & Now
  .WriteLine "==========================="
  .Close
End With

Set objOutputFile = Nothing
Set objFSO = Nothing
wscript.quit

Sub ProcessFolder(strSource)
  ProcessFiles strSource
  For Each fld In strSource.SubFolders
    ProcessFolder fld
  Next
End Sub

Sub ProcessFiles(strSrc)
  For Each file In strSrc.Files
    objOutputFile.WriteLine file.Path & " was relocated at " & Now
    objFSO.MoveFile file.Path, strTargetFolder
  End If
  Next
End Sub
0
indacryptAuthor Commented:
umm no...just using windows commands... thanks very much though
0
SteveGTRCommented:
@echo off

setlocal

REM ** Set debug= to activate code
set debug=echo

if "%~2"=="" echo Usage: %0 sourceDirectory destinationDirectory&goto :EOF
if not exist "%~1" echo %~1 does not exist&goto :EOF
if not exist "%~2" echo %~2 does not exist&goto :EOF

set srcDir=%~1
set destDir=%~2

REM ** This makes sure that the trailing backslash if specified is removed
REM ** I don't believe that works in 2000, so you'll have to make sure
REM ** that you don't specify a trailing backslash for the destination
REM if "%destDir:~-1%"=="\" set destDir=%destDir:~0,-1%

call :GETDATEPARTS "%date%"

call :SUBTRACTDAYS 2

set cutOff=%yy%%mm%%dd%

pushd "%srcDir%"

for /f "tokens=*" %%a in ('dir /b /a-d "%srcDir%" 2^>NUL') do call :PROCESS "%%a" %%~ta

popd

goto :EOF

:PROCESS

call :GETDATEPARTS %~2

%debug% if /i "%yy%%mm%%dd%" LSS "%cutOff%" move "%~1" "%destDir%\%~1"

goto :EOF

:GETDATEPARTS

set dt=%~1
set tok=1-3

if "%dt:~0,1%" GTR "9" set tok=2-4

set yyyy=

for /f "tokens=%tok% delims=.:/-, " %%a in ('echo %~1') do (
  for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do set %%x=%%a&set %%y=%%b&set %%z=%%c
)

if not "%yyyy%"=="" set yy=%yyyy%

if 1%yy% LSS 1000 (if %yy% LSS 70 (set yy=20%yy%) else (set yy=19%yy%))
if 1%mm% LSS 100 set mm=0%mm%
if 1%dd% LSS 100 set dd=0%dd%

goto :EOF

:SUBTRACTDAYS

set dayCnt=%1

if "%dayCnt%"=="" set dayCnt=1

REM Substract your days here
set /A dd=1%dd% - 100 - %dayCnt%
set /A mm=1%mm% - 100

:CHKDAY

if /I %dd% GTR 0 goto DONESUBTRACT

set /A mm=%mm% - 1

if /I %mm% GTR 0 goto ADJUSTDAY

set /A mm=12
set /A yy=%yy% - 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
REM ** Month 12 falls through

:SET31

set /A dd=31 + %dd%

goto CHKDAY

:SET30

set /A dd=30 + %dd%

goto CHKDAY

:LEAPCHK

set /A tt=%yy% %% 4

if not %tt%==0 goto SET28

set /A tt=%yy% %% 100

if not %tt%==0 goto SET29

set /A tt=%yy% %% 400

if %tt%==0 goto SET29

:SET28

set /A dd=28 + %dd%

goto CHKDAY

:SET29

set /A dd=29 + %dd%

goto CHKDAY

:DONESUBTRACT

if /I %mm% LSS 10 set mm=0%mm%
if /I %dd% LSS 10 set dd=0%dd%

goto :EOF

Good Luck,
Steve
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

indacryptAuthor Commented:
oh wow....didnt realise the script would be so long!! Ill try it ...ill have to give it two days to try it coz i manually psuhed the files over today. Will let you know.
Thanks!!
0
indacryptAuthor Commented:
i realised I dont have the expertise to modify that script so IM not going to be using either of these. Thanks!
0
SteveGTRCommented:
Don't have to modify mine all you have to do is run it with the parameters you specify. Run it without parameters to get the usage.

0
indacryptAuthor Commented:
Hi Steve...what parameters would I be using..do you mean i just rename srcDir and destDir?
0
SteveGTRCommented:
If you named the batch file MyMoveFile.bat you'd say:

MyMoveFile "c:\temp" "d:\temp"
0
SteveGTRCommented:
Here's the version that actually moves files:

@echo off

setlocal

REM ** Set debug= to activate code
set debug=

if "%~2"=="" echo Usage: %0 sourceDirectory destinationDirectory&goto :EOF
if not exist "%~1" echo %~1 does not exist&goto :EOF
if not exist "%~2" echo %~2 does not exist&goto :EOF

set srcDir=%~1
set destDir=%~2

REM ** This makes sure that the trailing backslash if specified is removed
REM ** I don't believe that works in 2000, so you'll have to make sure
REM ** that you don't specify a trailing backslash for the destination
REM if "%destDir:~-1%"=="\" set destDir=%destDir:~0,-1%

call :GETDATEPARTS "%date%"

call :SUBTRACTDAYS 2

set cutOff=%yy%%mm%%dd%

pushd "%srcDir%"

for /f "tokens=*" %%a in ('dir /b /a-d "%srcDir%" 2^>NUL') do call :PROCESS "%%a" %%~ta

popd

goto :EOF

:PROCESS

call :GETDATEPARTS %~2

%debug% if /i "%yy%%mm%%dd%" LSS "%cutOff%" move "%~1" "%destDir%\%~1"

goto :EOF

:GETDATEPARTS

set dt=%~1
set tok=1-3

if "%dt:~0,1%" GTR "9" set tok=2-4

set yyyy=

for /f "tokens=%tok% delims=.:/-, " %%a in ('echo %~1') do (
  for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do set %%x=%%a&set %%y=%%b&set %%z=%%c
)

if not "%yyyy%"=="" set yy=%yyyy%

if 1%yy% LSS 1000 (if %yy% LSS 70 (set yy=20%yy%) else (set yy=19%yy%))
if 1%mm% LSS 100 set mm=0%mm%
if 1%dd% LSS 100 set dd=0%dd%

goto :EOF

:SUBTRACTDAYS

set dayCnt=%1

if "%dayCnt%"=="" set dayCnt=1

REM Substract your days here
set /A dd=1%dd% - 100 - %dayCnt%
set /A mm=1%mm% - 100

:CHKDAY

if /I %dd% GTR 0 goto DONESUBTRACT

set /A mm=%mm% - 1

if /I %mm% GTR 0 goto ADJUSTDAY

set /A mm=12
set /A yy=%yy% - 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
REM ** Month 12 falls through

:SET31

set /A dd=31 + %dd%

goto CHKDAY

:SET30

set /A dd=30 + %dd%

goto CHKDAY

:LEAPCHK

set /A tt=%yy% %% 4

if not %tt%==0 goto SET28

set /A tt=%yy% %% 100

if not %tt%==0 goto SET29

set /A tt=%yy% %% 400

if %tt%==0 goto SET29

:SET28

set /A dd=28 + %dd%

goto CHKDAY

:SET29

set /A dd=29 + %dd%

goto CHKDAY

:DONESUBTRACT

if /I %mm% LSS 10 set mm=0%mm%
if /I %dd% LSS 10 set dd=0%dd%

goto :EOF
0
indacryptAuthor Commented:
when i try saying movelogs "D:\<path here>" "w:\" (w is a mapped network drive, no password required), it gives me an error saying the path on the D drive is invalid..!
0
SteveGTRCommented:
What exactly does it say?

Does it say:

d:\yourpath does not exist

Or some other message?

Can you reveal the path so that I can check it out?

Here's a version with debug information. Please report back what it says when you run this code:

@echo off

setlocal

REM ** Set debug= to activate code
set debug=

if "%~2"=="" echo Usage: %0 sourceDirectory destinationDirectory&goto :EOF
if not exist "%~1" echo %~1 does not exist&goto :EOF
if not exist "%~2" echo %~2 does not exist&goto :EOF

set srcDir=%~1
set destDir=%~2

REM ** This makes sure that the trailing backslash if specified is removed
REM ** I don't believe that works in 2000, so you'll have to make sure
REM ** that you don't specify a trailing backslash for the destination
REM if "%destDir:~-1%"=="\" set destDir=%destDir:~0,-1%

call :GETDATEPARTS "%date%"

call :SUBTRACTDAYS 2

set cutOff=%yy%%mm%%dd%

echo curOff=%cutOff%
echo srcDir=%srdDir%
echo destDir=%destDir%

pushd "%srcDir%"

echo After pushd command...

for /f "tokens=*" %%a in ('dir /b /a-d "%srcDir%" 2^>NUL') do call :PROCESS "%%a" %%~ta

After for command...

popd

echo After popd command...

goto :EOF

:PROCESS

call :GETDATEPARTS %~2

%debug% if /i "%yy%%mm%%dd%" LSS "%cutOff%" move "%~1" "%destDir%\%~1"

goto :EOF

:GETDATEPARTS

set dt=%~1
set tok=1-3

if "%dt:~0,1%" GTR "9" set tok=2-4

set yyyy=

for /f "tokens=%tok% delims=.:/-, " %%a in ('echo %~1') do (
  for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do set %%x=%%a&set %%y=%%b&set %%z=%%c
)

if not "%yyyy%"=="" set yy=%yyyy%

if 1%yy% LSS 1000 (if %yy% LSS 70 (set yy=20%yy%) else (set yy=19%yy%))
if 1%mm% LSS 100 set mm=0%mm%
if 1%dd% LSS 100 set dd=0%dd%

goto :EOF

:SUBTRACTDAYS

set dayCnt=%1

if "%dayCnt%"=="" set dayCnt=1

REM Substract your days here
set /A dd=1%dd% - 100 - %dayCnt%
set /A mm=1%mm% - 100

:CHKDAY

if /I %dd% GTR 0 goto DONESUBTRACT

set /A mm=%mm% - 1

if /I %mm% GTR 0 goto ADJUSTDAY

set /A mm=12
set /A yy=%yy% - 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
REM ** Month 12 falls through

:SET31

set /A dd=31 + %dd%

goto CHKDAY

:SET30

set /A dd=30 + %dd%

goto CHKDAY

:LEAPCHK

set /A tt=%yy% %% 4

if not %tt%==0 goto SET28

set /A tt=%yy% %% 100

if not %tt%==0 goto SET29

set /A tt=%yy% %% 400

if %tt%==0 goto SET29

:SET28

set /A dd=28 + %dd%

goto CHKDAY

:SET29

set /A dd=29 + %dd%

goto CHKDAY

:DONESUBTRACT

if /I %mm% LSS 10 set mm=0%mm%
if /I %dd% LSS 10 set dd=0%dd%

goto :EOF
0
indacryptAuthor Commented:
C:\>movelogs "D:\Program Files\KANA\Response Server\shareddir\logs\" "W:\"
curOff=20070408
srcDir=
destDir=W:\
After pushd command...
'After' is not recognized as an internal or external command,
operable program or batch file.
After popd command...

C:\>
0
SteveGTRCommented:
I forgot a echo statement on the one debugging line:

After for command...

Should be:

echo After for command...

I don't see any problems there. Where is the error about d:?
0
indacryptAuthor Commented:
Umm...well it doesnt show the src directory it just says "srcDIr =", and now even tho it runs without any errors, it hasnt moved any of the files either...
0
indacryptAuthor Commented:
the batchfile doesnt have to be located on the same drive as the srcDir does it?
0
SteveGTRCommented:
No it doesn't have to exist in the same directory. Here's another debug batch. Please post back results:

@echo off

setlocal

REM ** Set debug= to activate code
set debug=

if "%~2"=="" echo Usage: %0 sourceDirectory destinationDirectory&goto :EOF
if not exist "%~1" echo %~1 does not exist&goto :EOF
if not exist "%~2" echo %~2 does not exist&goto :EOF

set srcDir=%~1
set destDir=%~2

REM ** This makes sure that the trailing backslash if specified is removed
REM ** I don't believe that works in 2000, so you'll have to make sure
REM ** that you don't specify a trailing backslash for the destination
REM if "%destDir:~-1%"=="\" set destDir=%destDir:~0,-1%

call :GETDATEPARTS "%date%"

call :SUBTRACTDAYS 2

set cutOff=%yy%%mm%%dd%

echo curOff=%cutOff%
echo srcDir=%srdDir%
echo destDir=%destDir%

pushd "%srcDir%"

for /f "tokens=*" %%a in ('dir /b /a-d "%srcDir%" 2^>NUL') do call :PROCESS "%%a" %%~ta

popd

goto :EOF

:PROCESS

call :GETDATEPARTS %~2

echo if /i "%yy%%mm%%dd%" LSS "%cutOff%" move "%~1" "%destDir%\%~1"

goto :EOF

:GETDATEPARTS

set dt=%~1
set tok=1-3

if "%dt:~0,1%" GTR "9" set tok=2-4

set yyyy=

for /f "tokens=%tok% delims=.:/-, " %%a in ('echo %~1') do (
  for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do set %%x=%%a&set %%y=%%b&set %%z=%%c
)

if not "%yyyy%"=="" set yy=%yyyy%

if 1%yy% LSS 1000 (if %yy% LSS 70 (set yy=20%yy%) else (set yy=19%yy%))
if 1%mm% LSS 100 set mm=0%mm%
if 1%dd% LSS 100 set dd=0%dd%

goto :EOF

:SUBTRACTDAYS

set dayCnt=%1

if "%dayCnt%"=="" set dayCnt=1

REM Substract your days here
set /A dd=1%dd% - 100 - %dayCnt%
set /A mm=1%mm% - 100

:CHKDAY

if /I %dd% GTR 0 goto DONESUBTRACT

set /A mm=%mm% - 1

if /I %mm% GTR 0 goto ADJUSTDAY

set /A mm=12
set /A yy=%yy% - 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
REM ** Month 12 falls through

:SET31

set /A dd=31 + %dd%

goto CHKDAY

:SET30

set /A dd=30 + %dd%

goto CHKDAY

:LEAPCHK

set /A tt=%yy% %% 4

if not %tt%==0 goto SET28

set /A tt=%yy% %% 100

if not %tt%==0 goto SET29

set /A tt=%yy% %% 400

if %tt%==0 goto SET29

:SET28

set /A dd=28 + %dd%

goto CHKDAY

:SET29

set /A dd=29 + %dd%

goto CHKDAY

:DONESUBTRACT

if /I %mm% LSS 10 set mm=0%mm%
if /I %dd% LSS 10 set dd=0%dd%

goto :EOF
0
indacryptAuthor Commented:
if /i "20070410" LSS "20070409" move "log20070410_213008.xml" "W:\log20070410_2
3008.xml"
if /i "20070410" LSS "20070409" move "log20070410_213444.xml" "W:\log20070410_2
3444.xml"
if /i "20070410" LSS "20070409" move "log20070410_214029.xml" "W:\log20070410_2
4029.xml"
if /i "20070410" LSS "20070409" move "log20070410_214441.xml" "W:\log20070410_2
4441.xml"
if /i "20070410" LSS "20070409" move "log20070410_214911.xml" "W:\log20070410_2
4911.xml"
if /i "20070410" LSS "20070409" move "log20070410_215448.xml" "W:\log20070410_2
5448.xml"
if /i "20070410" LSS "20070409" move "log20070410_215932.xml" "W:\log20070410_2
5932.xml"
if /i "20070410" LSS "20070409" move "log20070410_220332.xml" "W:\log20070410_2
0332.xml"
if /i "20070410" LSS "20070409" move "log20070410_220651.xml" "W:\log20070410_2
0651.xml"
if /i "20070410" LSS "20070409" move "log20070410_221120.xml" "W:\log20070410_2
1120.xml"
if /i "20070410" LSS "20070409" move "log20070410_221449.xml" "W:\log20070410_2
1449.xml"
if /i "20070410" LSS "20070409" move "log20070410_221912.xml" "W:\log20070410_2
1912.xml"
if /i "20070410" LSS "20070409" move "log20070410_222410.xml" "W:\log20070410_2
2410.xml"
if /i "20070410" LSS "20070409" move "log20070410_222758.xml" "W:\log20070410_2
2758.xml"
if /i "20070410" LSS "20070409" move "log20070410_223113.xml" "W:\log20070410_2
3113.xml"
if /i "20070410" LSS "20070409" move "log20070410_223611.xml" "W:\log20070410_2
3611.xml"
if /i "20070410" LSS "20070409" move "log20070410_224006.xml" "W:\log20070410_2
4006.xml"
0
indacryptAuthor Commented:
i couldnt capture the first half of the debug....coz it started printing thisout...but again, none of the files have really been moved..like the names of the files that it mentions, are still in the src directory on the D drive
0
SteveGTRCommented:
Look's like all of the files I can see were updated 4/10/2007. The compare date is 4/9/2007.

I do a less than comparision of:

if 4/10/2007 LSS 4/9/2007 Do the move

None of the files meet the requirement.
0
indacryptAuthor Commented:
But I need to move the files for the last 2 days....so I need to move files for the 9th and 10th..
0
SteveGTRCommented:
Sorry my mistake :)

@echo off

setlocal

REM ** Set debug= to activate code
set debug=

if "%~2"=="" echo Usage: %0 sourceDirectory destinationDirectory&goto :EOF
if not exist "%~1" echo %~1 does not exist&goto :EOF
if not exist "%~2" echo %~2 does not exist&goto :EOF

set srcDir=%~1
set destDir=%~2

REM ** This makes sure that the trailing backslash if specified is removed
REM ** I don't believe that works in 2000, so you'll have to make sure
REM ** that you don't specify a trailing backslash for the destination
REM if "%destDir:~-1%"=="\" set destDir=%destDir:~0,-1%

call :GETDATEPARTS "%date%"

call :SUBTRACTDAYS 2

set cutOff=%yy%%mm%%dd%

echo curOff=%cutOff%
echo srcDir=%srdDir%
echo destDir=%destDir%

pushd "%srcDir%"

for /f "tokens=*" %%a in ('dir /b /a-d "%srcDir%" 2^>NUL') do call :PROCESS "%%a" %%~ta

popd

goto :EOF

:PROCESS

call :GETDATEPARTS %~2

if /i "%yy%%mm%%dd%" GEQ "%cutOff%" move "%~1" "%destDir%\%~1"

goto :EOF

:GETDATEPARTS

set dt=%~1
set tok=1-3

if "%dt:~0,1%" GTR "9" set tok=2-4

set yyyy=

for /f "tokens=%tok% delims=.:/-, " %%a in ('echo %~1') do (
  for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do set %%x=%%a&set %%y=%%b&set %%z=%%c
)

if not "%yyyy%"=="" set yy=%yyyy%

if 1%yy% LSS 1000 (if %yy% LSS 70 (set yy=20%yy%) else (set yy=19%yy%))
if 1%mm% LSS 100 set mm=0%mm%
if 1%dd% LSS 100 set dd=0%dd%

goto :EOF

:SUBTRACTDAYS

set dayCnt=%1

if "%dayCnt%"=="" set dayCnt=1

REM Substract your days here
set /A dd=1%dd% - 100 - %dayCnt%
set /A mm=1%mm% - 100

:CHKDAY

if /I %dd% GTR 0 goto DONESUBTRACT

set /A mm=%mm% - 1

if /I %mm% GTR 0 goto ADJUSTDAY

set /A mm=12
set /A yy=%yy% - 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
REM ** Month 12 falls through

:SET31

set /A dd=31 + %dd%

goto CHKDAY

:SET30

set /A dd=30 + %dd%

goto CHKDAY

:LEAPCHK

set /A tt=%yy% %% 4

if not %tt%==0 goto SET28

set /A tt=%yy% %% 100

if not %tt%==0 goto SET29

set /A tt=%yy% %% 400

if %tt%==0 goto SET29

:SET28

set /A dd=28 + %dd%

goto CHKDAY

:SET29

set /A dd=29 + %dd%

goto CHKDAY

:DONESUBTRACT

if /I %mm% LSS 10 set mm=0%mm%
if /I %dd% LSS 10 set dd=0%dd%

goto :EOF
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
indacryptAuthor Commented:
GEQ..ah okie...i tried GTE lol. This one gets stuck after it echoes the destDir tho...:( THanks for your prompt replies. Much appreciated!
0
SteveGTRCommented:
Where it echo's destDir?

My last solution doesn't echo destDir... what are you talking about?
0
indacryptAuthor Commented:
echo curOff=%cutOff%
echo srcDir=%srdDir%
echo destDir=%destDir%
0
indacryptAuthor Commented:
C:\>movelogstest "D:\Program Files\KANA\Response Server\shareddir\logs" "W:"
curOff=20070409
srcDir=
destDir=W:
if /i "20070410" GEQ "20070409" move "log20070410_160041.xml" "W:\log20070410_16
0041.xml"
if /i "20070410" GEQ "20070409" move "log20070410_160312.xml" "W:\log20070410_16
0312.xml"
if /i "20070410" GEQ "20070409" move "log20070410_160539.xml" "W:\log20070410_16
0539.xml"
if /i "20070410" GEQ "20070409" move "log20070410_160810.xml" "W:\log20070410_16
0810.xml"
if /i "20070410" GEQ "20070409" move "log20070410_161008.xml" "W:\log20070410_16
1008.xml"
if /i "20070410" GEQ "20070409" move "log20070410_161309.xml" "W:\log20070410_16
1309.xml"
if /i "20070410" GEQ "20070409" move "log20070410_161517.xml" "W:\log20070410_16
1517.xml"
if /i "20070410" GEQ "20070409" move "log20070410_161705.xml" "W:\log20070410_16
1705.xml"
if /i "20070410" GEQ "20070409" move "log20070410_161932.xml" "W:\log20070410_16
1932.xml"
if /i "20070410" GEQ "20070409" move "log20070410_162238.xml" "W:\log20070410_16
2238.xml"
if /i "20070410" GEQ "20070409" move "log20070410_162436.xml" "W:\log20070410_16
2436.xml"
if /i "20070410" GEQ "20070409" move "log20070410_162726.xml" "W:\log20070410_16
2726.xml"
if /i "20070410" GEQ "20070409" move "log20070410_163024.xml" "W:\log20070410_16
3024.xml"
if /i "20070410" GEQ "20070409" move "log20070410_163300.xml" "W:\log20070410_16
3300.xml"
0
SteveGTRCommented:
Can you run the most recent version I published?
0
indacryptAuthor Commented:
thats the one....i posted the above results from that. ijust echoed the GEQ line
0
SteveGTRCommented:
Okay, and it stops or hangs up you say? When does it do that?
0
indacryptAuthor Commented:
it stops soon after it prints the "destDIr=" line
0
indacryptAuthor Commented:
sorry..it hangs soon after that line.not stops
0
SteveGTRCommented:
I'm sorry but the code I most recently posted doesn't echo:

destDIr=

Please post the code you are running.
0
indacryptAuthor Commented:
it looks like it worked!! sorry..there were just too man files to move i guess and i thought it had hung becoz nothing was showing up ion the dest dir.! i see that theyre there now tho. THaaank you!!
0
SteveGTRCommented:
Glad it worked :)
0
indacryptAuthor Commented:
To run this as a scheduled task, can i use the scheduler in windows and then in the "Run" box I just enter "c:\movelogs "D:.." "w:""
?
0
SteveGTRCommented:
You could do that, but you might get into trouble access network resources under the default system account. You'll want to specify run as and set it to a domain user, like yourself. Also, you might to better to use a UNC instead of a mapped drive. Like this:

c:\movelogs d:\yourdir \\server1\share1\directory

0
indacryptAuthor Commented:
c:\movelogs d:\yourdir \\server1\share1\directory.. here movelogs in the name of my batch file..so are you saying i just add the source and destination directories after that? (like  i do from the command prompt)...not sure what a UNC is..sorry!
0
SteveGTRCommented:
Basically you are referencing the network resource without the mapped drive.

Type net use and it will show you what the drive making is.
0
indacryptAuthor Commented:
thanks a TON steve!
0
indacryptAuthor Commented:
actually..that doesnt work on the win2000 machine :(
0
SteveGTRCommented:
What doesn't work?
0
indacryptAuthor Commented:
net use. I'mmoving the files to the root directory of the mapped drive, so I didnt quite follow what you meant by  c:\movelogs d:\yourdir \\server1\share1\directory..
0
SteveGTRCommented:
Net use works on 2000 and XP.

You'd only need to use the UNC (\\server\etc...) if you were accessing a network resource through a mapped drive in a scheduled task.

The problem is that you can't be sure that w: or whatever will be mapped when the scheduled task is run. Do you understand that?
0
indacryptAuthor Commented:
Yep i understood that:) wasnt sure how that UNC works!
0
indacryptAuthor Commented:
aaah...never mind!!! i got what youre saying...youre sayign istead of just saying w: which is the mapped drive, provide the entire path for the mapped drive..correct?
0
SteveGTRCommented:
That is correct :)
0
indacryptAuthor Commented:
thanks:)..again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.