Inkscape.org
Beyond the Basics I want to process multiple SVG files at once using a batch.
  1. #1
    TOMINO TOMINO @TOMINO

    Please help me.

    I have generated a batch script using ChatGPT to perform the following operations:

    1. Drag and drop the SVG file to be processed into the batch file.
    2. Open the SVG file.
    3. Group the objects in the document.
    4. Resize the objects in the document to a size of 48px × 48px or smaller while maintaining the aspect ratio.
    5. Set the document size to 52px × 52px.
    6. Align the object to the center of the document.
    7. Set the object's color code to #FFFFFF.
    8. Place a rectangle with a color code of #162142 at the bottom of the object.
    9. Output the converted SVG file and PNG image in the specified folder.
    10. Read the next file and perform steps 2-10.

    The following code generated by ChatGPT does not apply "8. Set the object's color code to #FFFFFF" to the output files. How can it be fixed?

    ---<Code>---

    @echo off

    set output_folder=C:\Output
    set inkscape_path="C:\Users\<UserName>\Desktop\InkscapePortable\App\Inkscape\bin\inkscape.com"
    set object_color=#FFFFFF
    set rect_color=#162142

    for %%f in (%*) do (
      echo Processing file: %%f
      "%inkscape_path%" --verb=FitCanvasToDrawing --verb=Group --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FitSelectedToPage --verb=SelectionUnGroup --verb=EditSelectAll --verb=ObjectToSelection --verb=ObjectMakeMask --verb=EditDeselect --verb=ObjectToSelection --verb=ObjectRemoveMask --verb=EditSelectAll --verb=ObjectToPath --verb=ObjectUngroup --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=Group --verb=GroupFillSetForegroundColor:%object_color% --verb=FillSetForegroundColor:%rect_color% --verb=FitCanvasToDrawing --verb=FileSave --verb=FileQuit %%f
      "%inkscape_path%" --export-type=svg --export-filename="%output_folder%\%%~nf.svg" %%f
      "%inkscape_path%" --export-type=png --export-filename="%output_folder%\%%~nf.png" --export-width=52 --export-height=52 --export-background="%rect_color%" "%output_folder%\%%~nf.svg"
    )

  2. #2
    inklinea inklinea @inklinea⛰️

    The Inkscape command line alone cannot create new elements.

    It can duplicate but not create.

    Also what ChatGPT has created does not make any sense.

    If you are using Inskcape 1.2+

    Use inkscape --action-list to list the actions you can use in this format : inkscape --actions="action1;action2" etc

  3. #3
    TOMINO TOMINO @TOMINO

    @inklinea

     

    Thank you for your response!

    It seems that the code generated by ChatGPT has no meaning. It's unfortunate, but I'm glad I was able to find out.

    I will try to incorporate the Inkscape 1.2 command line.

    Thank you very much!

Inkscape Inkscape.org Inkscape Forum Beyond the Basics I want to process multiple SVG files at once using a batch.