忽略批处理文件百分号 [英] Ignore percent sign in batch file

查看:115
本文介绍了忽略批处理文件百分号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从一个文件夹文件移动到另一个批处理文件。由另一个过程中产生的批处理文件。

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

我的一些需要移动有字符串%20,在他们的文件:

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 any way to ignore %? I'm not able to alter the file generated to escape this, such as by doubling percent signs (%%), escaping with / or ^ (caret), etc.

推荐答案

您应该能够使用插入符号(^)<一个href=\"http://windowsitpro.com/article/articleid/39047/how-can-i-pass-a-percent-sign--value-to-regexe.html\"相对=nofollow>逃脱百分号。

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

究其原因%2 正在消失是该批处理文件替换第二个参数传入,和你似乎没有第二个参数。要解决这个问题的方法是实际尝试 foo.bat ^%^ 1%2 ... ,以便当%2 在命令中遇到,它实际上是与取代文字%2

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.

这篇关于忽略批处理文件百分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆