I converted a bunch of PDFs into individual SVGs for editing. The SVGs are named as the page numbers, so I have a whole folder of 001.svg, 002.svg ... and the problem is they all the objects in each SVG are grouped together and I have ungroup everything before I can edit the pages which takes a few minutes on each page.
Would save some time if I could ungroup all the pages from the command line first. I've looked at the inkscape command line options and maybe this is actually a windows command prompt or powershell question too because I'm not sure how to loop through files incrementally in either of those
I saw some question here for ungrouping from the command line with
inkscape --actions "select-all:groups; SelectionUnGroup; export-filename: output.svg; export-plain-svg; export-do;" intput.svg
But even trying that one individual files nothing happens, I did replace inkscape with the full path
Anyone know how to accomplish this? Thanks!
There should be an easier way by using the 'deep ungroup' Python script from the command line.
Unfortunately, I can only give you the syntax for Linux, so you need to adjust the paths and the '>' (which means 'output into the following file') to your Windows paths and PowerShell syntax.
With default extension settings, it works like so:
python3 /usr/share/inkscape/extensions/ungroup_deep.py groups.svg > ungrouped.svg
Alright I believe I have solved it. For some reason I don't think it's possible to do this using the "without-gui" flag which is unfortunate. But this is what I ended up using (still takes a few minutes per file, but doesn't require any work on my part"
I'm using Inkscape 0.92 for reference (I believe this would not work in later versions)
#echo off
for %%i in ("%~dp0*.svg") do (
echo %%i
"C:\Program Files\Inkscape\inkscape.exe" -f "%%i" --verb EditSelectAll --verb
SelectionUnGroup --verb FileSave --verb FileQuit
)
Related
I'm using a Windows batch script in Powershell to convert all numbered .svg files in a folder to .png, using Inkscape on the commandline, based on the answer to a previous question here.
#echo off
for %%i in ("%~dp0*.svg") do (
echo %%i to %%~ni.png
"C:\Program Files\Inkscape\bin\inkscape.com" --export-type="png" --export-background-opacity=1.0 "%%i"
)
The script calls Inkscape again for each file, which I suspect is the main speed bottleneck (I have many files to convert). I would prefer to call Inkscape once and provide the list of files to convert.
Is it possible to use --shell mode to do this? I cannot find an example that uses this approach.
One approach I found was to use the interactive --shell mode with a sequence of "actions" and "verbs" such as this:
inkscape --shell
> file-open:file001.svg;export-filename:file001.png;export-do; file-open:file002.svg;export-filename:file002.png;export-do;
You can generate a long list of these action and verb sequences, one for each file. It works very well, but unfortunately I wasn't able to paste a large enough text string for the thousands of SVG files I wanted to convert. I think Powershell is limited by the amount of text you can paste into it, as is the usual command prompt.
Therefore it would be great if a future version of Inkscape accepted batch file containing such a list of commands. Currently it doesn't seem possible, as far as I can tell from the documentation.
Following on from your own answer, I created a 10,000 line file called inkscape.cmd that looks like this:
inkscape-version
inkscape-version
inkscape-version
...
...
and ran it with:
inkscape --shell < inkscape.cmd
I have only tested this on macOS as I don't have Windows.
I have a ogr2ogr command and I am mixing the command with windows shell command
I have to loop through certain extensions only, which is *.shp. And, the command below is where I started
for %f in (*.shp) do (ogr2ogr .....
but now I have to loop through files with this kind of name.
road_node_1.shp
road_node_2.shp
...
road_node_9.shp
I played around with many types of wildcard such as
for %f in (road_node_*) do (ogr2ogr .....
then it loops through all the files that are related to the *.shp and the file name (without the extension) is same
road_node_1.shx
road_node_1.dbf
road_node_1.cpg
road_node_1.prj..
so It does go though unnecessary files, which takes more time to do process
I tried the command below and doesn't work either
for %f in (road_node_*.shp) do (ogr2ogr .....
I wonder if there is a way to loop through file names like that.
#Aacini
This is weird...
the command did not work a few hours ago
for %f in (road_node_*.shp) do
now... this command works like a magic.
I do not know what has been changed though issue solved :(
I've managed to activated beyond compare using command line:
"C:\Program Files\Beyond Compare 4\BComp.exe" /qc /iu /K "file1.c" "file2.c" & echo %errorlevel & exit
this allows me to get the result of comparison in cmd ERRORLEVEL variable.
I wan't to be able to set the file format used for this comparison.
Manually, I can set it via the GUI through "format" button on the ribbon.
anyone know how this can be done?
I've looked in the beyond compare scripting reference but to no avail.
thank you!
Jack
Beyond Compare doesn't support forcing a file format with a command-line switch.
If the file extension is .c, Beyond Compare will use the built-in C/C++ file format. To use a different file format, open Tools > File Formats. The highest file format in the list with a matching file mask is used. To force a file format to be used regardless of mask, move it to the top of the list and set the file mask to *.*.
See the Command Line Reference topic in Beyond Compare's help file for supported command line parameters.
This is a slightly different use case. I often find myself comparing some JSON that I've copied to something else. Both the snippets exist in a clipboard manager that stores the clipboard history.
If you are using ZSH then you can use process substitution to do this as follows (note the =()):
bcomp -fv="Text Compare" =(pbpaste) =(pbpasteother)
The above generates temporary files which store the output of the commands (pbpaste , pbpasteother etc) and then sends them to Beyond Compare which is none the wiser. The only notable this is that you use bcomp which is the name of the command line tool that Beyond Compare installs which waits for a return code
However, the above doesn't allow me to compare the snippets as JSON.
However, with ZSH, one can also set the extension:
(TMPSUFFIX=.json; bcomp -fv="Text Compare" =(pbpaste) =(pbpasteother) )
We want to do the above in subshell to avoid impacting the current shell's env.
And that works!
I'm trying to create a .cfg file for bcc32 compiler and I'm following the instructions. I have installed correctly and placed an environment path as instructed but when I type "edit bcc32.cfg" into the command prompt it says that edit isn't a valid command? What am I supposed to do?
You could also create a .bat file, edit.bat, to replace the 16-bit edit program (removed because x64 windows flavors won't run it) which would launch your favorite editor.
#echo off
notepad %1
#echo on
This is what I wound up doing as a simple patch so I could carry on the way I always had for the most part. Just type:
edit myfile.ext
in the command prompt to use it.
Note: notepad is not my favorite editor - this is just an example that will work with stock windows.
Note 2: #echo off and #echo on are shown for clarity. You may also shorten this by omitting the echo statements and simply placing the # before the command to be silenced.
#notepad %1
I just use notepad (since they took out the edit command) from the command window like so:
C:\Borland\BCC55\bin> notepad bcc32.cfg
The file will open in notepad for editing. When you've finished editing the file, save it and you're done.
I have found this works for seeing in-window text of a complete file, on a 64bit machine. Once your path is set in cmd prompt, type the word type... followed by "filename" do you see how I used the quotes around the filename only!
type "filename"
You type it just like this (changing filename for your files name) and you will be able to see the entire file text in the cmd window. Not sure how to edit from here on but maybe someone can figure it out from here and tell me.
Assuming you're using Windows 7 (where edit.exe and edlin.exe have been removed):
Use powershell.exe instead of cmd - thereby edit will be available via command line.
Take a look at: http://en.wikipedia.org/wiki/Windows_PowerShell
simple answer....
if your using an old version of windows (xp e.t.c...) you would be able to use edit
but since your using new version of windows, Microsoft has updated and removed the commands that they think are not relevant e.g.. (msg, edit) depending if its a bit32 bit64 or bit82...
Inside Vim on Windows, I'm trying to filter the lines in a file through a shell executable. I'm using the following command:
:0,$!sort
The idea being that I'll sort the lines of the file using the Windows sort command.
The issue is that I get nothing back so, effectively, all the lines in the file are deleted, i.e. they are replaced with nothing (I can recover all the lines using undo u).
Outside of Vim, the following command works fine:
type sort-lines.txt | sort
("sort-lines.txt" is the test file that I'm working with in vim.)
I've tried this with the Windows sort command as well as with the Cygwin sort command. The results are the same.
Interestingly, if I use the following command in Vim:
:0,$!dir
The lines of the file are replaced with the output from the dir command. This makes me think that the external program is executing, but it isn't correctly receiving the input lines from the file.
Is there something that needs to be adjusted in my configuration to make this work? I checked the value of Vim's shellpipe option and it is set to:
shellpipe=>%s 2>&1
which doesn't seem right to me.
Okay, I found the issue.
I had an Autorun CMD script set in my registry. Whenever vim would spin up CMD to run the filter, the Autorun script would run and somehow block the piped-in data from getting in.
To workaround the issue, I changed the value of the vim "shell" variable. Here is what I set it to.
:set shell=C:\Windows\system32\cmd.exe\ /d
The /d tells CMD not to run any Autorun scripts. The extra backslash after the "cmd.exe" is necessary in order to escape the space character between cmd.exe and the /d.
With this setting in place, filtering works correctly.
For a discussion of Autorun and the /d option see this MSDN article
Thanks, Darcy, for pointing me in the right direction. (BTW, you have a great last name.)
vim has a built-in sort utility. You can try that.
:0,$sort