Hi,
I try to convert and create a new image with suffix " _web" for many images in folders and subfolders
example i have this folders
c:\test\
c:\test\myimage\image.jpg
c:\test\allimages\myimages.jpg
i try to use this
c:
cd c:\test
FOR /R %%a IN (*.jpg) DO convert %%a -resample 72 -units pixelsperinch -colorspace RGB -set filename:original %%t_web.jpg %%[filename:original]
the script work, but put all "_web" images in a main directory c:\test
how to save the image _web in a right folder?
to have this
c:\test\
c:\test\myimage\image.jpg
c:\test\myimage\image_web.jpg
c:\test\allimages\myimages.jpg
c:\test\allimages\myimages_web.jpg
thanks!!
batch convert
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: batch convert
In your convert command, you must tell IM where to find the input image and where to put the output image. You can get all images from one directory and put them into separate directories, but you must tell IM which subdirectory to use for each output image. Are all your input images coming from the parent test directory?
Note you can process all images in a given directory using mogrify.
Why are you converting to colorspace RGB? Are you on a very old version of IM when RGB and sRGB were swapped? Currently RGB is linear and sRGB is non-linear and what most people expect to see.
Note you can process all images in a given directory using mogrify.
Why are you converting to colorspace RGB? Are you on a very old version of IM when RGB and sRGB were swapped? Currently RGB is linear and sRGB is non-linear and what most people expect to see.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: batch convert
You can include a folder (aka directory) name in the output filename. This could be %d -- see http://www.imagemagick.org/script/escape.phpNatul wrote:how to save the image _web in a right folder?
Or you could do it with the Windows mechanism: %%~dpa
snibgo's IM pages: im.snibgo.com
Re: batch convert
ok, I realized that the problem is that I do not set the correct IM in output subfolders.
I dont understand how I can add this information to my script? to save converted image " _Web" in the correct subfolder?
sorry I am beginner to IM
thanks
I dont understand how I can add this information to my script? to save converted image " _Web" in the correct subfolder?
sorry I am beginner to IM
thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: batch convert
I pointed you to documentation http://www.imagemagick.org/script/escape.php . That shows you that %t is "filename without directory or extension (suffix)". It also shows you that %d is "directory component of path". In Windows BAT, you need to double the % signs. For IM, I think a backslash here also needs to be doubled. So try using "%%d\\%%t" instead of "%%t".
snibgo's IM pages: im.snibgo.com
Re: batch convert
ok work! with %%d\\%%t thank you!!!
Re: batch convert
I have another question,
this script work but only if i dont have a space in a name of folders or files.
FOR /R %%a in (*.jpg) DO convert %%a -resample 72 -units pixelsperinch -colorspace RGB -set filename:original %%d\\%%t_web.jpg %%[filename:original]
where i put the " " to use it when i have a space in folders name or files?
thanks!!!
this script work but only if i dont have a space in a name of folders or files.
FOR /R %%a in (*.jpg) DO convert %%a -resample 72 -units pixelsperinch -colorspace RGB -set filename:original %%d\\%%t_web.jpg %%[filename:original]
where i put the " " to use it when i have a space in folders name or files?
thanks!!!
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: batch convert
I would start by putting doublequotes around the first use of the variable "%%a" after "convert", and around the filename where you set it in the command, and around the filename where you use it at the end of the command.Natul wrote: ↑2017-02-11T05:58:49-07:00this script work but only if i dont have a space in a name of folders or files.
FOR /R %%a in (*.jpg) DO convert %%a -resample 72 -units pixelsperinch -colorspace RGB -set filename:original %%d\\%%t_web.jpg %%[filename:original]
where i put the " " to use it when i have a space in folders name or files?
Code: Select all
FOR /R %%a in (*.jpg) DO (
convert "%%a" -resample 72 -units pixelsperinch -colorspace RGB ^
-set filename:original "%%d\\%%t_web.jpg" "%%[filename:original]"
)