views:

262

answers:

1

I have a batch file which moves files from one folder to another. The batch file is generated from another process.

Some of the files I need to move have the string "%20" in them:

move /y "\\myserver\myfolder\file%20name.txt" "\\myserver\otherfolder"

This fails as it tries to find a file with the name:

\\myserver\myfolder\file0name.txt

Is there anyway to ignore % sign? I'm not able to alter the file generated to escape this. e.g. double percent sign %%, / or ^ carrot, etc.

+1  A: 

You should be able to use a carat (^) to escape a percent sign.

The reason %2 is disappearing is that the batch file is substituting the second argument passed in, and your seem to not have a second argument. One way to work around that would be to actually try foo.bat ^%1 ^%2... so that when a %2 is encountered in a command, it is actually substituted with a literal %2.

Mark Rushakoff
sorry can't alter the file produced.
Stagg
Cool that works well. Thanks.
Stagg