KANEWONG
asked on
Batch script not function as expected.
Hi;
I have a batch script running on a W2K3 server, (see in code section), this batch file would check if any file exist in K:\PO\archive folder, if it is; it will copy the file to k:\po folder, if not exist, it will display a message.
Howerver; I cannot get "IF NOT EXIST k:\po\archive\*.* GOTO NOFILE" command line working. It always go to BEGIN section eventhough there is no file in k:\po\archive folder.
Any idea?
I have a batch script running on a W2K3 server, (see in code section), this batch file would check if any file exist in K:\PO\archive folder, if it is; it will copy the file to k:\po folder, if not exist, it will display a message.
Howerver; I cannot get "IF NOT EXIST k:\po\archive\*.* GOTO NOFILE" command line working. It always go to BEGIN section eventhough there is no file in k:\po\archive folder.
Any idea?
@echo off
rem This is a batch program to copy the raw data file from Archive folder back to PO folder
:CHK
cls
set folder1=k:\po\archive
set folder2=k:\po
IF NOT EXIST k:\po\archive\*.* GOTO NOFILE
:BEGIN
dir %folder1%\*.#???????
echo.
set /p yn=Confirm to restore this file to K:\PO folder ? y/n
if "%yn%"=="" (echo Not entry) & (GOTO CHK)
if /I "%yn%"=="n" (GOTO QUIT)
if /I "%yn%"=="y" (GOTO FRESTORE) else (echo Entry not y or n!) & (GOTO CHK)
:FRESTORE
ECHO START MOVING...
robocopy %folder1% %folder2% *.* /mov /maxage:0 /s
cls
dir k:\po\*.#???????
echo.
echo ************************************************************************
echo ** If you can see the file listed now, your file restore is complete. **
echo ** Run AGAIN. **
echo ************************************************************************
echo.
echo ___________________________________________________________
echo If you do not see the file restored, please try again or
echo.
echo contact I.T. Dept by e-mail or phone.
echo ___________________________________________________________
:END
echo.
set yn=
set /p yn=Do this again [y/n]?
if "%yn%"=="" (echo Not entry) & (GOTO END)
if /I "%yn%"=="n" (GOTO QUIT)
if /I "%yn%"=="y" (GOTO CHK) else (echo Entry not y or n!) & (GOTO END)
:NOFILE
echo.
echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
echo x No file found in k:\po\archive folder, x
echo x it could be done already. x
echo x No file restore can be done at this time. x
echo x Asking I.T. Dept for further assistance. x
echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
pause
:QUIT
EXIT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER