Windows 10 system, using cmd
I have a NAS full of images, buried deep in a series of subfolders. I am trying to write a script to reduce all images older than 90days from BMP to jpg.
What I have so far,
forfiles /P [dir1\dir2\....] /S /M *.bmp /D -90 /C "cmd /c magick morgify @fname -format jpg *.bmp"
When i run this command, it does process the BMP to JPG as needed, but it then tries to run again and again creating ~jpg files and errors in cmd line i assume bc the jpg file names exist.
What I also need is a way to remove the original BMP file, my NAS is 0.06% empty and can't afford to create double pictures
Script to convert BMP to JPG, Need help completing.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Script to convert BMP to JPG, Need help completing.
"magick mogrify" loops through all the files in its input filename, in your case "*.bmp". But you have this inside a "forfiles" loop which loops through "*.bmp". So every file is processed twice.
I suggest you use "forfiles" with "magick", so the magick command processes only one file at a time. You can also have a "delete" command within the loop.
I suggest you use "forfiles" with "magick", so the magick command processes only one file at a time. You can also have a "delete" command within the loop.
snibgo's IM pages: im.snibgo.com
Re: Script to convert BMP to JPG, Need help completing.
Thanks for that @snibgo
I was able to create a pretty decent script once i remembered i can link CMDs with &
my final working script is:
forfiles /S /M *.bmp /D -120 /C "cmd /c echo @file & convert @file @fname.jpg & DEL @file"
I was able to create a pretty decent script once i remembered i can link CMDs with &
my final working script is:
forfiles /S /M *.bmp /D -120 /C "cmd /c echo @file & convert @file @fname.jpg & DEL @file"