With the latest version of Magick.NET your batch file roughly translates to this:
string outputDirectory = @"c:\output"; int sizeX = 1280; // set SIZEX=1280int sizeY = 720; // set SIZEY=720int offsetX = -1; //set OFFSETX=-1int offsetY = -1; //set OFFSETY=-1// del "output\*.png"foreach (string fileName in Directory.GetFiles(outputDirectory, "*.png")) { File.Delete(fileName); } // convert "*.png"foreach (string fileName in Directory.GetFiles(@"c:\input", "*.png")) { using (MagickImage source = new MagickImage(fileName)) { foreach (MagickImage image in source.CropToTiles(sizeX, sizeY)) // -crop %SIZEX%x%SIZEY% { // -set filename:tile "%%t %%[fx:page.x/%SIZEX%+%OFFSETX%]_%%[fx:page.y/%SIZEY%+%OFFSETY%]"// This does not do the -set operation but it is easier to just put filename:tile in a variable.string name = image.FormatExpression(string.Format("%t %[fx:page.x/{0}+{1}]_%[fx:page.y/{2}+{3}]", sizeX, offsetX, sizeY, offsetY)); // "output\%%[filename:tile].png" image.Write(outputDirectory + "\\" + name + ".png"); } } }