- 1 year ago
Inkscape commandline convert list of files
To convert a list of files using the Inkscape command-line interface, you can use a loop or a script to iterate over the files and execute the conversion command for each file. Here's an example using a Bash script:
bash#!/bin/bash
# List of input files
files=("input1.svg" "input2.svg" "input3.svg")
# Output directory
output_dir="output/"
# Iterate over the files and convert each one
for file in "${files[@]}"; do
# Generate the output filename by replacing the file extension
output_file="${file%.*}.png"
# Run the Inkscape command to convert the file
inkscape -z -e "$output_dir$output_file" "$file"
# Display a message for each conversion
echo "Converted $file to $output_file"
done
In this example, you need to modify the files
array to contain the list of input SVG files you want to convert. Set the output_dir
variable to the desired output directory where the converted PNG files will be saved.
The script uses a for
loop to iterate over each file in the files
array. It generates the output filename by replacing the file extension with .png
. The Inkscape command (inkscape -z -e
) is then executed for each file, converting it to PNG format. Finally, a message is displayed for each conversion.
Save the script to a file (e.g., convert.sh
), make it executable (chmod +x convert.sh
), and run it using ./convert.sh
in a Bash terminal.
Note: This example assumes you have Inkscape installed and added to your system's PATH. Adjust the command (inkscape
) if necessary to provide the full path to the Inkscape executable.
By using this script as a starting point, you can adapt it to suit your specific needs, such as handling different input/output file formats or adding additional conversion options supported by Inkscape.