|
Answer» hey all,
I am having trouble getting a BATCH to work correctly. Basically what I wish to do is COPY the entire contents of a server folder to a folder in the current dir. I have everything working except that there is a space after %A%. see below:
Code: [Select]@echo OFF :START CLS SET ANSWER=
echo DO YOU WISH TO COPY THE NEW PD DATA SETS? ECHO. ECHO.
SET /P ANSWER=YES OR NO:
IF '%ANSWER%' =='' echo %ANSWER% is not a valid choice && GOTO START
echo %ANSWER% |findstr /i /r "[n]" > NUL
IF /I %errorlevel% EQU 0 echo you chose no && GOTO STOP
GOTO COPY
:COPY
CLS
echo NOW SETTING UP TO COPY DATA SETS ECHO. ECHO.
REM SERVER AND FOLDER PATH TO PD DATA
SET PDPATH=\\[server]\[share]\
REM THIS WILL MAKE THE TEXT FILE THAT THE NEWEST PD DATA REM FOLDERS WILL BE ADDED TO.
echo 5745-ALACHUA> %TEMP%\PDFILEINFO.TXT echo 5630-BAKER>> %TEMP%\PDFILEINFO.TXT echo 5653-BAY>> %TEMP%\PDFILEINFO.TXT echo 5466-BRADFORD >> %TEMP%\PDFILEINFO.TXT
REM THIS WILL SET UP THE COUNT set count=0
REM THIS WILL PULL THE INFORMATION FROM THE PDFILEINFO.TXT FILE REM AND SET IT UP FOR USE.
SET FILELOC=%TEMP%\PDFILEINFO.TXT CLS FOR /f "usebackq tokens=1" %%A in ("%FILELOC%") do ( SET A=%%A && CALL :GETDATA %%A )
echo JOB COMPLETED!
IF EXIST "%TEMP%\PDFILEINFO.TXT" DEL "%TEMP%\PDFILEINFO.TXT" PAUSE GOTO STOP
:GETDATA
SET F2=%A:~0,2%00
MKDIR "%CD%\%A%"
ping -n 1 -w 1000 1.1.1.1 > nul
echo "%PDPATH%%F2%\%A%" echo "%CD%\%A%\"
pause XCOPY "%PDPATH%%F2%\%A%" "%CD%\%A%" /E /I /Y
SET /A count=%count%+1 ECHO %count% Folder %A% CREATED
PAUSE
:STOP
please let me know if you can see something I am doing wrong.
thanks, wayne1. set A=%%A& CALL:GETDATE %%A
2. set/a count+=1 is more simple though both will works.
3. IF '%ANSWER%' =='' echo %ANSWER% is not a valid choice && GOTO START the space in if STATEMENT will cause trouble, not sure why you use && if '%ANSWER%'='' echo ......
statement1 && statement2 if the result of statement1 is not errorlevel 1, then execute statement2
statement1 & statement2 execute statement1, then statement2 no matter the errorlevel of statement1
4. IF /I %errorlevel% EQU 0 echo you chose no && GOTO STOP what the uppercase or lowercase of '0'?
sorry if i make a lot of comments thanks but that dose not answer my original issue.
Why am I getting a space after %A% when it pulls from the text file?Quote from: wbrost on May 20, 2009, 07:45:00 AM thanks but that dose not answer my original issue.
Why am I getting a space after %A% when it pulls from the text file?
You PROBABLY have a trailing space on a line - you may not be able to see it, but the computer can and it will be significant to it GrahamQuote from: wbrost on May 20, 2009, 07:45:00 AMthanks but that dose not answer my original issue.
Why am I getting a space after %A% when it pulls from the text file?
i already gave answer for that on no.1, the extra space if not from text file. original code: Code: [Select]SET A=%%A && CALL :GETDATA %%Anotice the space between %%A and &&, that's where the extra space coming from you could modify it to SET A=%%A& CALL :GETDATA %%A or SET A=%%A CALL :GETDATA %%A
ok, actually there is one statement that cause another extra space, but the for loop nullify the effect of the extra space: echo 5466-BRADFORD >> %TEMP%\PDFILEINFO.TXT modify to: echo 5466-BRADFORD>>%TEMP%\PDFILEINFO.TXT or >>%TEMP%\PDFILEINFO.TXT echo 5466-BRADFORDok thanks was trying to make it read better.... oh well thanks.
|