Hi,
I am trying to make a command to use Image Magick command: convert <curpath> -resize 460 -quality 75 <curpath>\460px\%03d.jpg
I have tried putting quotation marks every which way around the run command and I just can't figure it out..
Anyone know how I would format the run command to run that string for folders with spaces in them like example if <curpath> was C:\Files and Images\Images by Size\ .. is there a curpath that shortens the path DOS style or am I just not formatting the string right?
I hope this makes sense
Thanks
Scripting Trouble with long file name with spaces
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Scripting Trouble with long file name with spaces
Hi and Welcome,
I am not sure if its a mistake or you are trying something i don't know. You syntax starts with:
convert <curpath>
I think you have to also provide a file name to convert a file to something else.
Also, I think the below syntax should work for you if you change the paths accordingly. I tested this from by copy/pasting the code into Scripting>Try script:
hope that helps.
I am not sure if its a mistake or you are trying something i don't know. You syntax starts with:
convert <curpath>
I think you have to also provide a file name to convert a file to something else.
Also, I think the below syntax should work for you if you change the paths accordingly. I tested this from by copy/pasting the code into Scripting>Try script:
Code: Select all
//ImageMagick script to convert selected image to new.jpg
focus;
run "cmd /k cd /d C:\Program Files\ImageMagick\ & convert <curitem> -quality 75 -resize 460 <curpath>\new.jpg"
-
wowglide
- Posts: 4
- Joined: 28 Oct 2010 06:47
Re: Scripting Trouble with long file name with spaces
Oops, I worded my command wrong here is the correct one:serendipity wrote:Hi and Welcome,
I am not sure if its a mistake or you are trying something i don't know. You syntax starts with:
convert <curpath>
I think you have to also provide a file name to convert a file to something else.
Also, I think the below syntax should work for you if you change the paths accordingly. I tested this from by copy/pasting the code into Scripting>Try script:hope that helps.Code: Select all
//ImageMagick script to convert selected image to new.jpg focus; run "cmd /k cd /d C:\Program Files\ImageMagick\ & convert <curitem> -quality 75 -resize 460 <curpath>\new.jpg"
convert <curpath>\*.jpg -resize 460 -quality 75 <curpath>\460px\%03d.jpg
this makes the image magick convert.exe convert all JPEGs in the current directory then the %03d.jpg is just to incremental number them, does this make sense? I think the whole \*.jpg is what is throwing off my syntax
-
admin
- Site Admin
- Posts: 67271
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Scripting Trouble with long file name with spaces
I surely can be done, but I have to know what syntax is expected by ImageMagick. Can you give a wellformed example?
FAQ | XY News RSS | XY X
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Scripting Trouble with long file name with spaces
Oh ok, this should work (tested it myself):wowglide wrote:Oops, I worded my command wrong here is the correct one:
convert <curpath>\*.jpg -resize 460 -quality 75 <curpath>\460px\%03d.jpg
this makes the image magick convert.exe convert all JPEGs in the current directory then the %03d.jpg is just to incremental number them, does this make sense? I think the whole \*.jpg is what is throwing off my syntax
Code: Select all
//Converts all jpgs in current folder to 000.jpg, 001.jpg and so on.
focus;
run "cmd /k cd /d C:\Program Files\ImageMagick\ & convert <curpath>\*.jpg -quality 75 -resize 460 <curpath>\%03d.jpg"
-
wowglide
- Posts: 4
- Joined: 28 Oct 2010 06:47
Re: Scripting Trouble with long file name with spaces
It craps out when the <curpath> returns a long path with spaces, example <curpath> returns C:\My Pictures\Tuesday Album\ .. cmd doesn't like spaces, How do I add quotes around the path, I tried the double quotes around it but it errors out.serendipity wrote:Oh ok, this should work (tested it myself):wowglide wrote:Oops, I worded my command wrong here is the correct one:
convert <curpath>\*.jpg -resize 460 -quality 75 <curpath>\460px\%03d.jpg
this makes the image magick convert.exe convert all JPEGs in the current directory then the %03d.jpg is just to incremental number them, does this make sense? I think the whole \*.jpg is what is throwing off my syntax
Good luck.Code: Select all
//Converts all jpgs in current folder to 000.jpg, 001.jpg and so on. focus; run "cmd /k cd /d C:\Program Files\ImageMagick\ & convert <curpath>\*.jpg -quality 75 -resize 460 <curpath>\%03d.jpg"
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Scripting Trouble with long file name with spaces
Sorry, I am bad at quoting myself.wowglide wrote:It craps out when the <curpath> returns a long path with spaces, example <curpath> returns C:\My Pictures\Tuesday Album\ .. cmd doesn't like spaces, How do I add quotes around the path, I tried the double quotes around it but it errors out.serendipity wrote:Oh ok, this should work (tested it myself):wowglide wrote:Oops, I worded my command wrong here is the correct one:
convert <curpath>\*.jpg -resize 460 -quality 75 <curpath>\460px\%03d.jpg
this makes the image magick convert.exe convert all JPEGs in the current directory then the %03d.jpg is just to incremental number them, does this make sense? I think the whole \*.jpg is what is throwing off my syntax
Good luck.Code: Select all
//Converts all jpgs in current folder to 000.jpg, 001.jpg and so on. focus; run "cmd /k cd /d C:\Program Files\ImageMagick\ & convert <curpath>\*.jpg -quality 75 -resize 460 <curpath>\%03d.jpg"
This worked for me (I also double quoted the ImageMagick path)
Code: Select all
//Converts all jpgs in current folder to 000.jpg, 001.jpg and so on.
focus;
run "cmd /k cd /d ""C:\Program Files\ImageMagick\"" & convert ""<curpath>\*.jpg"" -quality 75 -resize 460 ""<curpath>\%03d.jpg"""
-
wowglide
- Posts: 4
- Joined: 28 Oct 2010 06:47
Re: Scripting Trouble with long file name with spaces
Works! Thanks so much for your help, I worked on it for a hour or so last night trying to get it to work lolserendipity wrote:Sorry, I am bad at quoting myself.wowglide wrote:It craps out when the <curpath> returns a long path with spaces, example <curpath> returns C:\My Pictures\Tuesday Album\ .. cmd doesn't like spaces, How do I add quotes around the path, I tried the double quotes around it but it errors out.serendipity wrote:Oh ok, this should work (tested it myself):wowglide wrote:Oops, I worded my command wrong here is the correct one:
convert <curpath>\*.jpg -resize 460 -quality 75 <curpath>\460px\%03d.jpg
this makes the image magick convert.exe convert all JPEGs in the current directory then the %03d.jpg is just to incremental number them, does this make sense? I think the whole \*.jpg is what is throwing off my syntax
Good luck.Code: Select all
//Converts all jpgs in current folder to 000.jpg, 001.jpg and so on. focus; run "cmd /k cd /d C:\Program Files\ImageMagick\ & convert <curpath>\*.jpg -quality 75 -resize 460 <curpath>\%03d.jpg"
This worked for me (I also double quoted the ImageMagick path)
Code: Select all
//Converts all jpgs in current folder to 000.jpg, 001.jpg and so on. focus; run "cmd /k cd /d ""C:\Program Files\ImageMagick\"" & convert ""<curpath>\*.jpg"" -quality 75 -resize 460 ""<curpath>\%03d.jpg"""
XYplorer Beta Club