简体   繁体   English

批处理文件将当前文件夹发送到带引号的参数中

[英]batch file send current folder inside a quoted argument

I have a batch file for converting images, arguments are quotes, and quotes strings inside the argument are escaped. 我有一个用于转换图像的批处理文件,参数是引号,并且引号内的引号字符串已转义。 However, I want to send the current path %CD %also as an argument... but executing this: 但是,我想将当前路径%CD%也作为参数发送...但是执行此操作:

"C:\Program Files\GIMP 2\bin\gimp-2.8.exe"  -i -b "(python-fu-watermark-folder RUN-INTERACTIVE \"%CD%\" \"%CD%_watermarked\" \"C:/Documents and Settings/Jan/Desktop/watermarking/customEffectsWatermark.png\")"  -b "(gimp-quit 0)"

gives me an echoed: 给我回声:

C:\Documents and Settings\Jan\Desktop\watermarking\tester>"C:\Program Files\GIMP2\bin\gimp-2.8.exe"  -i -b "(python-fu-watermark-folder RUN-INTERACTIVE \"C:\Documents and Settings\Jan\Desktop\watermarking\tester\" \"C:\Documents and Settings\Jan\Desktop\watermarking\tester_watermarked\" \"C:/Documents and Settings/Jan/Desktop/watermarking/customEffectsWatermark.png\")"  -b "(gimp-quit 0)"

which is nice, however, the backslashes from the directory are escape characters! 很好,但是目录中的反斜杠是转义字符! so while executing the plugin I end up with a escaped directory (I dont want that): 因此,在执行插件时,我最终得到一个转义的目录(我不想要这样):

WatermarkFolder-Warning: C:Documents and SettingsJanDesktopwatermarking ester
WatermarkFolder-Warning: C:Documents and SettingsJanDesktopwatermarking ester_watermarked
WatermarkFolder-Warning: files to be processed in total: 0

As I have no control over the path, is there a way to escape the escapecharacters? 由于我无法控制路径,是否有一种方法可以逃脱转义符? Thanks! 谢谢! Lode 洛德

Did you try making a variable with the value of %CD% double escaped? 您是否尝试过将%CD%的值制成双精度转义变量?

Something like this: 像这样:

set mycd=%cd:\=\\%

And using %mycd% where you were using %cd% 并在使用%cd%的地方使用%mycd%

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM