Reputation:
I've put together the batch file below; I don't have much experience with batch files and I can't figure out why the file fails with an error message stating that the:
DO command was unexpected.
Looking at the following code, does anyone know what I did wrong? Thanks.
@ECHO OFF
REM Set arguments supplied by Subversion
SET REPOS = %1
SET REV = %2
REM Set working directory path
SET WORKSPACE = D:\apache\htdocs
REM Assign changes to variable
SET CHANGES = svnlook changed %REPOS% -r %REV%
REM Update only changed files
FOR /f %%a IN %CHANGES% DO svn update %%a
Upvotes: 1
Views: 2434
Reputation:
After modifying my original code I've got it to 'work.' The svnlook command returns for example: trunk\images\smileyface.jpg
Currently, the for loop returns only the 'U' rather than the 'smileyface.jpg' which I want. So, while the code now works, it does function yet how I'd like (still working on it).
Below is the revamped code (Note: I had to remove all spaces between my variables and their assigned values).
@ECHO OFF
REM Set arguments supplied by Subversion
SET REPOS=%1
SET REV=%2
REM Set working directory path
SET WORKSPACE=D:\apache\htdocs
REM Assign changes to variable
SET CHANGES=svnlook changed %REPOS% -r %REV%
REM Update only changed files
FOR /F "usebackq" %%a IN (`%CHANGES%`) DO (svn update %%a)
Upvotes: 0
Reputation: 51729
FOR /f %%a IN %CHANGES% DO svn update %%a
should be
FOR /f %%a IN (%CHANGES%) DO svn update %%a
Hope this helps,
Upvotes: 6
Reputation: 4721
can you try to run it without the REM Statement. Comments sometimes make things work differently.
Upvotes: 0
Reputation: 12304
I'm guessing that %CHANGES%
is not in the correct format/structure for the loop so the DO
cannot be executed. Add the following line before the loop to check you're getting what you expected from the SET CHANGES
command;
ECHO %CHANGES%
If the assignment is more batch code to execute you might need to use CALL
. What are you passing in when calling the batch file for %1
and %2
?
Upvotes: 0