0

I need to make a .bat in Windows that does the following: Open a huge amount of .jpg files with paint and then resave them. They can be overwritten or saved into a new folder, that doesn't matter.

My code is the following:

mkdir newFolder 
FOR %%x in (*.jpg) DO mspaint %%x > newFolder/new%%x

The problem is that the file saved is not a copy of the original one. I can't just copy all the files because they HAVE to pass trough paint, but cant figure out where the problem is.

When I open that new file it just shows a black image with the text "new0001.jpg".

Factor Mystic
  • 26,279
  • 16
  • 79
  • 95
R3dolaf
  • 5
  • 1
  • 4
  • 1
    Why do they have to pass through mspaint? If you explain what you are trying to do someone might have an answer, but it is unlikely to involve mspaint. Depending on what you want to accomplish, something like Irfanview - it's free, lightweight, and can operate in batch mode - might be a choice. – William Feb 25 '13 at 18:51

4 Answers4

1

Mspaint is not designed for batch usage. It has no command line option to save a file. You could look at a windows scripting solution (where your script essentially clicks on menu items in mspaint to save the file and close), or look at different graphics packages such as those suggested here: MS Paint command line switches

Community
  • 1
  • 1
Nate Hekman
  • 6,507
  • 27
  • 30
  • Well, it's kind of silly. A frined of mine has some kind of e-reader that sometimes get messed up wit the images files (he uses it to read comics, I guess). He called the IT departament of the e-reader and they told him that he needed to make the operation I said before. So he called me and asked if I could automatize the process, so here I am. I tried to do the following: `mkdir newFolder FOR %%x in (*.jpg) DO type %%x > newFolder/new%%x` But didnt work. Images saver O.K. but the problem was still there. – R3dolaf Feb 25 '13 at 22:01
0

I didn't verified it, but with Image Magick convert it should be something like:

FOR %%x in (*.jpg) DO convert %%x newFolder\%%~nx.png

(where %%~nx stands for "filename without extension", if the enhanced syntax is available, otherwise you would have to use %%x.png and the files will be named as foo.jpg.png).

Javier
  • 12,100
  • 5
  • 46
  • 57
  • But they haven't to be converted, just "fisically" opened...anu suggestions? – R3dolaf Feb 26 '13 at 07:49
  • 1
    Image Magick `convert` is just the name of the executable. You wouldn't have to convert from jpeg to png. You could convert from jpeg to jpeg, and maybe try the `-strip` option to strip out embedded comments. It's not converting anything so much as just opening and re-saving. If Javier's suggestion doesn't work, then you might look into the image resizer powertoy, or use IrfanView's batch operation to mass save every jpeg. – rojo Feb 27 '13 at 21:21
0

this is for the option to check all pictures to edit manual . . . only because uve used the words "open with paint" . . conflict between what u want and how i can see thats possible and there 2 differnt questions in your words. maybe u can create a mix of both scripts for your own perfection

@echo off
for %%a in (myfolder\*.*) do (
echo %%a
start mspaint %%a
)
pause
exit
0
@echo off

set newName=copied
set newType=bmp
set /a amount=0



for %%i in (myfolder\*.*) do (
set /a amount+=1
call echo %%amount%% %%i
call xcopy %%i myfolder\nextFolder\%%newName%%%%amount%%.%%newType%%
)

pause

exit

ive realized now thats musst be possible somehow to work with the "mkdir" command . . . iam not funny with the questions of the cmdWindow of "file or data"

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32079082) – Andreas Jun 29 '22 at 08:11