4

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:

"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

lode
  • 504
  • 6
  • 21

1 Answers1

6

Did you try making a variable with the value of %CD% double escaped?

Something like this:

set mycd=%cd:\=\\%

And using %mycd% where you were using %cd%

andre.barata
  • 663
  • 3
  • 11
  • While typing the question I was thinking this but I am not used to work with Batch files, and was happily entering whitespace before and after the "=" from the set variable. aaargh. So, thanks a lot for showing me that no spaces are allowed if I want it to work :) It works! – lode Jul 02 '13 at 19:24