Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a batch file intended to replace all instances of tracking.js within a folder/sub folders.

FOR /R "D:\Virtual Servers (Testing)\CourseWare Master\Shared\Jenison\Version1.2\" %%I IN (tracking.js*) DO COPY /Y "D:\Virtual Servers (Testing)\CourseWare Master\Shared\Jenison\tracking.js" %%~fI

When this is run I get the following syntax error

C:>COPY /Y "D:\Virtual Servers (Testing)\CourseWare Master\Shared\Jenison\track ing.js" D:\Virtual Servers (Testing)\CourseWare Master\Shared\Jenison\Version1.2 \SHAPERS_COMBINED\Smarter Communications\WhatisInfluencing\script\Tracking.js The syntax of the command is incorrect.

Ideas please?

share|improve this question
1  
You have a space in the target path too - I think this should also be encapsulated with " – Xyon Nov 20 '12 at 16:40
up vote 0 down vote accepted

I think you need to quote %%~fI as it expands to a path with spaces.

FOR /R "D:\Virtual Servers (Testing)\CourseWare Master\Shared\Jenison\Version1.2\" %%I IN (tracking.js*) DO COPY /Y "D:\Virtual Servers (Testing)\CourseWare Master\Shared\Jenison\tracking.js" "%%~fI"
share|improve this answer
    
Many thanks for that – Ralph Nov 20 '12 at 17:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .