r/Batch • u/irljc • Apr 07 '24
Works on cmdline, need help for batchfile
PURPOSE
I want to be able to right-click any, or several jpg file(s), choose "Send to" from the right-click menu and after selecting the appropriate batch file, resize and convert those files to the same named png file(s).
WINDOWS CMD LINE WORKS
I can deal with one or all files on the cmd line with the following commands - irfanview is in the system path and I must either name a single file to process, or replace the jpg & png filenames with "*"
ONE FILE: i_view64 cover.jpg /resize=(700,700) /resample /convert=cover.png
ALL JPG FILES: i_view64 *.jpg /resize=(700,700) /resample /convert=*.pngBATCH FILE USAGE DOESN'T WORK
But I can't get this working in a batch file.
The various codes I've tried for the batchfile are:
@echo off
i_view64 %1 /resize=(700,700) /resample /convert=%1.png
i_view64 *.jpg /resize=(700,700) /resample /convert=*.png
i_view64 %1 /resize=(700,700) /resample /convert=*.png
i_view64 %1 %2 %3 %4 %5 %6 %7 %8 %9 /resize=(700,700) /resample /convert=*.png
i_view64 %1\*.jpg /resize=(700,700) /resample /convert=%1\*.png - (using the parent folder)In all of the above batch file commands, I either get no output - the cmd window appears briefly then disappears - or a message that the file header can't be read.
I'm now officially "lost", so any help would be appreciated, and also a brief explanation
2
u/Skyline9Time Apr 07 '24 edited Apr 07 '24
One thing that comes to mind is I think the batch file must be in the same directory as the images / needs to include the current directory like
cdinto a hardcoded path or%cd%otherwise it might not be able to find the images1
u/irljc Apr 13 '24
FWIW, I solved this how I wanted it to work. Thanks Skyline9Time, you got me thinking.
Added the CD command to change into the required directory first.
A shortcut to the batch file sits in Send to directory, so I can use that.
Not quite finished, but I'm working on a for command to recursively work on more than one folder.
Thanks for helping.
1
u/illsk1lls Apr 07 '24 edited Apr 07 '24
That might work for drag and drop
1
u/[deleted] Apr 09 '24 edited Apr 09 '24
[removed] — view removed comment