Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Trying to build a cmdline tool for reviewing TFS changesets. Currently I have this:

rem I know there's redundancy here, but don't care for now
set /A curr=%1
set /A prev=%curr%
set /A prev-=1

for /f "tokens=2" %g in ('tf changeset /noprompt %curr%') do tf diff /noprompt /format:unified /version:C%prev%~C%curr% %g

Which gives the following result:

g:\>tfdiffchangeset.bat 2458
currunified was unexpected at this time.

I'm not even sure why the : is turning into "curr", but if I remove /format, I get the same thing happening in /version.

Secondarily, if I just replace the :'s with spaces assuming I'll deal with that later, I get this error

g:\>tfdiffchangeset.bat 2458
The following usage of the path operator in batch-parameter
substitution is invalid: %~C%curr% %g

For valid formats type CALL /? or FOR /?
The syntax of the command is incorrect.

Is it time to write tfdiffchangeset.pl?

Final Version:

@ECHO off

set /A CURR=%1
rem Note - just using one changeset less doesn't necessarily work, because branches also use the same changeset numbers
set /A PREV=%CURR%-1

echo diffs for %CURR%

tf changeset /noprompt %CURR%

for /f "tokens=2" %%g in ('tf changeset /noprompt %CURR%') do tf diff /noprompt /format:unified /version:"C%PREV%~C%CURR%" %%g
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try:

for /f "tokens=2" %%g in ('tf changeset /noprompt %curr%') do tf diff /noprompt /format:unified /version:C%prev%~C%curr% %%g

From HELP FOR:

To use the FOR command in a batch program, specify %%variable instead
of %variable. Variable names are case sensitive, so %i is different
from %I.

share|improve this answer
    
Seems you got rid of the issue with the :, now there's the ~ issue. <br/> g:\eddynet\EddynetDependent>tfdiffchangeset 2464 <br/> The following usage of the path operator in batch-parameter substitution is invalid: %~C%curr% %g <br/> For valid formats type CALL /? or FOR /? <br/> The syntax of the command is incorrect. –  Tom Aug 31 '10 at 16:00
    
Actually, I'll give you the answer, since you made me look at the help, which told me to use upper case to deal with the ~ –  Tom Aug 31 '10 at 16:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.