Score:1

Inkscape CLI batch conversion of svg to eps using terminal / CLI

cz flag

I'm trying to batch convert svg vector files to EPS files but having trouble.

Command I'm using:

for file in /tmp/0/*.svg; do inkscape "$file" -o "${file%svg}eps" --export-ignore-filters --export-ps-level=3; done

Error I'm getting:

Gtk-Message: 12:09:52.418: Failed to load module "canberra-gtk-module"
Gtk-Message: 12:09:52.420: Failed to load module "canberra-gtk-module"

** (org.inkscape.Inkscape:948538): WARNING **: 12:09:52.682: Can't open file: /tmp/0/test20016.svg (doesn't exist)

** (org.inkscape.Inkscape:948538): WARNING **: 12:09:52.682: Can't open file: /tmp/0/test20016.svg (doesn't exist)
ink_file_open: '/tmp/0/test20016.svg' cannot be opened!
InkscapeApplication::document_open: Failed to open: /tmp/0/test20016.svg
ConcreteInkscapeApplication::on_open: failed to create document!
Gtk-Message: 12:09:52.956: Failed to load module "canberra-gtk-module"
Gtk-Message: 12:09:52.958: Failed to load module "canberra-gtk-module"

** (org.inkscape.Inkscape:948666): WARNING **: 12:09:53.223: Can't open file: /tmp/0/test20022.svg (doesn't exist)

** (org.inkscape.Inkscape:948666): WARNING **: 12:09:53.224: Can't open file: /tmp/0/test20022.svg (doesn't exist)
ink_file_open: '/tmp/0/test20022.svg' cannot be opened!
InkscapeApplication::document_open: Failed to open: /tmp/0/test20022.svg
ConcreteInkscapeApplication::on_open: failed to create document!

The file is there and can be opened using the GUI of inkscape

I'm using the snap version of Inkscape: Inkscape 1.2.2 (b0a8486541, 2022-12-01, custom)

inkscape /tmp/0/test20016.svg

Fails to open file:

Gtk-Message: 12:30:49.665: Failed to load module "canberra-gtk-module"
Gtk-Message: 12:30:49.667: Failed to load module "canberra-gtk-module"

** (org.inkscape.Inkscape:966787): WARNING **: 12:30:49.981: Can't open file: /tmp/0/test20016.svg (doesn't exist)

** (org.inkscape.Inkscape:966787): WARNING **: 12:30:49.981: Can't open file: /tmp/0/test20016.svg (doesn't exist)
ink_file_open: '/tmp/0/test20016.svg' cannot be opened!
InkscapeApplication::document_open: Failed to open: /tmp/0/test20016.svg
ConcreteInkscapeApplication::on_open: failed to create document!

Other commands work as expected:

$ for file in /tmp/0/*.svg; do ls "$file"; done 
/tmp/0/test20016.svg 
/tmp/0/test20022.svg

I did a sudo apt install libcanberra-gtk-module libcanberra-gtk3-module but still has issues with the canberra-gtk-module

I'm running Ubuntu 20.04 LTS: Linux sys76 5.15.0-57-generic #63~20.04.1-Ubuntu SMP Wed Nov 30 13:40:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:    20.04
Codename:   focal
terdon avatar
cn flag
That's odd. Can there be a process deleting these files between the moment when the `for file in /tmp/0/*.svg` list is populated and the moment the inkscape command runs? Is this inskcape-specific? Does `for file in /tmp/0/*.svg; do ls "$file"; done` work as expected?
cz flag
@terdon when I do a `/tmp/0/svg$ for file in /tmp/0/*.svg; do ls "$file"; done` I get: `/tmp/0/test20016.svg` `/tmp/0/test20022.svg`
terdon avatar
cn flag
And does `inkscape /tmp/0/test20016.svg` open the file normally?
cz flag
@terdon No it fails I updated the question to include output. But inkscape will execute when inkscape is run from the terminal
terdon avatar
cn flag
Hmm. I've never used snaps, but I know they use some sort of squashfs file system. It might be that from the command line, the `/tmp` refers to a different location and cannot be understood from within the snap but there is some sort of compatibility layer when you do it from the GUI. But I'm clutching at straws here and imagining things, I have no idea if I'm right.
terdon avatar
cn flag
Does `cd /tmp/0/svg && inkscape test20016.svg` do any better?
cz flag
@terdon That fails to run I even tried putting the files in my home directory to see if that would help but inkscape doesn't seem to launch with a file parameter from the terminal.
terdon avatar
cn flag
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/141979/discussion-between-terdon-and-rick-t).
Score:2
cz flag

Thanks goes to terdon for working with me on this.

Just tried it with the appimage and it worked....(so this snap has issues with some CLI commands)

Command I used to get it to work.

1- Download the appimage https://inkscape.org/release/inkscape-1.2.2/gnulinux/appimage/dl/

2- chmod u+x Inkscape-b0a8486-x86_64.AppImage

3- Run the command:

for file in /tmp/0/svg/*.svg; do ./Inkscape-b0a8486-x86_64.AppImage "$file" -o "${file%svg}eps" --export-ignore-filters --export-ps-level=3; done
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.