1

I run the following in Windows 10 command line;

convert file.png %t-test.png
convert file.png '%t-test.png'

And I get the following files;

%t-test.png
'%t-test.png'

How can I have the expected file-test.png be properly escaped and generated?

Update

Tried some others per @DavidPostill's suggestions;

>convert file.png '\%t-test.png'
convert.exe: unable to open image `'\%t-test.png'': No such file or directory @ error/blob.c/OpenBlob/2702.
convert.exe: WriteBlob Failed `'\%t-test.png'' @ error/png.c/MagickPNGErrorHandler/1630.

Also, both of the following result in '%t-test.png' being written;

convert file.png '%%t-test.png'
convert file.png '^%t-test.png'
9
  • Your question is unclear. What is this convert program you are running? What is this %t you are referring to?
    – DavidPostill
    Feb 15, 2016 at 13:20
  • The program is ImageMagick as tagged... Feb 15, 2016 at 20:18
  • So what's the %t?
    – DavidPostill
    Feb 15, 2016 at 20:19
  • It's an ImageMagick percentage escape per the title... Feb 15, 2016 at 20:21
  • Try adding the windows command line escape (backslash) to allow the convert escape (percent) to pass through: convert file.png '\%t-test.png'
    – DavidPostill
    Feb 15, 2016 at 20:27

1 Answer 1

2

I have determined the following workaround, although it limits output to what variable manipulations are available in cmd rather that what could be accomplished with ImageMagick percent escapes.

FOR %a IN (*.png) DO convert "%a" "test-%~na%~xa"

Based on these batch file variables;

%~a    expands %a removing any surrounding quotes (")
%~fa    expands %a to a fully qualified path name
%~da    expands %a to a drive letter only
%~pa    expands %a to a path only
%~na    expands %a to a file name only
%~xa    expands %a to a file extension only

More here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .