Dave
Dave

Reputation: 8897

Trouble copying a file in a Windows batch script

In Windows XP, I want it to copy the only file matching the pattern, selenium*.jar to a local directory.

I have tried:

pushd \\remote.mydomain.com\selenium\
FOR %f IN (selenium*.jar) DO copy %f C:\selenium

in which \\remote.mydomain.com is a shared directory, whose contents are hosted on a remote server.

But I get the error:

C:\selenium>pushd \\remote.mydomain.com\selenium\
f was unexpected at this time.

Upvotes: 1

Views: 193

Answers (1)

Doc Brown
Doc Brown

Reputation: 20044

Replace %f with %%f in your script. %fworks only if you entering the command directly at the command prompt, but not in a batch file. And typing help for on the command line shows you the manual where this behaviour is described in the second paragraph.

Upvotes: 2

Related Questions