Page 1 of 1

Convert Windows batch script to C#

Posted: 2020-03-25T17:44:48-07:00
by ElPeta
Hi all,

I have a windows batch script that adds a watermark to every jpg file it finds on a given folder, and sequentially renames it to "IMGxxx.jpg". It works perfectly, but I want to put it in a Windows form in C#. I have already referenced Magick.NET in my C# solution, but syntax is way different than I had figured out for batch coding.

My script looks like this:

Code: Select all

for /L %%i in (1,1,%cnt%) do ^
composite -dissolve 70% ^
-geometry +80+80 ^
-gravity southwest ^
Logo/MyLogoName.png ^
Input/IMG%%i.jpg Output/IMGwm%%i.jpg
Could someone please help? I'm clueless!

Thanks in advance.

Re: Convert Windows batch script to C#

Posted: 2020-03-25T18:03:15-07:00
by snibgo
Where is the difficulty? Your program could simply have a loop, and build the "composite" command and call it within the loop.

Re: Convert Windows batch script to C#

Posted: 2020-03-25T20:29:17-07:00
by ElPeta
Thanks Snibgo. The difficulty is that I don't know how to do this. How do I build the "composite" command within a loop, and then call it?

Re: Convert Windows batch script to C#

Posted: 2020-03-25T20:50:07-07:00
by snibgo
I suggest you read C# documentation, for example at https://docs.microsoft.com/en-us/dotnet/csharp/