Page 1 of 1
Processing Subfolders
Posted: 2011-08-24T05:50:18-07:00
by TSchlaier01
I know there are a few topics about a similar problem but I wasn't able to find a solution in the replies.
I want to process a folder including all subfolders. My (Batch)Script does that using the /R command but it saves all the results into the root directory.
Code: Select all
for /R %%f in (*.jpg) do ( convert "%%f" -resize 2480x3508 "%%~nf.jpg" )
I want to overwrite the original files in the subdirectories keeping the filenames.
Re: Processing Subfolders
Posted: 2011-08-24T16:56:16-07:00
by anthony
Re: Processing Subfolders
Posted: 2011-08-25T01:01:58-07:00
by TSchlaier01
I know that but I can't find a solution there.
The first example saves all output files into the root directory.
All the other examples there are very complex, using multiple batch files.
Isn't it possible to solve that problem with a single command? All I want to do is overwriting the existing files where they are!?
Re: Processing Subfolders
Posted: 2012-08-21T08:54:47-07:00
by almuhammedi
Try this
Code: Select all
for /R %%f in (*.jpg) do ( convert "%%f" -resize 2480x3508 "%%~npf.jpg" )
Regards,
Re: Processing Subfolders
Posted: 2012-08-21T09:48:48-07:00
by pipitas
I'm always hesitant to overwrite original files... but you asked for it
The shortest ImageMagick command to manipulate images 'inline' is
mogrify:
Code: Select all
for /R %%f in (*.jpg) do mogrify -resize 2480x3508 "%%f"
You can of course use convert too, but then you'll have to specifically set the output file path+name too...
Re: Processing Subfolders
Posted: 2012-08-21T10:49:48-07:00
by fmw42
with mogrify you can set the -path for the output directory so that you do not write over your input images
Re: Processing Subfolders
Posted: 2012-08-21T23:57:00-07:00
by whugemann
Well, the simplest code to perform this job is just
FOR /R %%f IN (*.jpg) DO convert "%%f" -resize 2480x3508 "%%f"
The code is so easy is that I would just type it into a CMD box, in which case it would be
FOR /R %f IN (*.jpg) DO convert "%f" -resize 2480x3508 "%f"
I intentionally don't give examples like that on the Windows Usage page, because I would rather never do a thing like that, i.e. possibly overwriting thousands of files.
Re: Processing Subfolders
Posted: 2012-08-22T01:11:47-07:00
by pipitas
whugemann wrote:Well, the simplest code to perform this job is just
FOR /R %%f IN (*.jpg) DO convert "%%f" -resize 2480x3508 "%%f"
So you think that's simpler than using 'mogrify' with only 1 occurrence of '%%f' ??
I share your hesitation to overwrite files, though.
Re: Processing Subfolders
Posted: 2012-08-22T02:18:48-07:00
by whugemann
pipitas wrote:
So you think that's simpler than using 'mogrify' with only 1 occurrence of '%%f' ??
I should have written "the most straightforward way for an IM beginner" instead of "simpler". To me, Mogrify is one of the more exotic command line tools. The IM beginner is probably more used to Convert.