Skip to main content
100%

read all svg file name in current dir -> edit svg text -> export

✓ Published0🌍 Public
HHirosaji
Last edited Dec 24, 2019
Created on Dec 24, 2019

This example reads every SVG file in the current directory, extracts its `viewBox` dimensions, and writes a modified copy to an `output` subfolder. Each file’s width and height attributes are explicitly set from the viewBox values, using Node.js’s `fs`, `path`, and `xmlhttprequest` modules to load and parse the raw SVG markup. The script filters files by extension, applies a regular expression to match the viewBox, and then performs a string replacement before saving the edited files. The result is a batch-processed set of SVGs with explicit dimensions for use in web contexts.

AI-generated description

Similar vizzes