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.
Related
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
)
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 am trying to run the below command to compress file size of images on Windows system and it returns error message:
Invalid Parameter 70
for %f IN (*.png) DO convert -quality 70 "%f" "%f"
I tried searching in world wide web for a solution, but couldn't find anything.
Is the syntax of the command wrong?
OR
Does this not work at all?
What am I missing here?
You have to specify the full path to your convert command (ex: if you installed convert.exe to C:\myprogs provide C:\myprogs\convert.exe in your for loop) or DOS will use the built-in convert command , which is completely different (NTFS/FAT volume conversion)
On my machine (I haven't installed any convert programs):
C:\Users\xxxx>where convert
C:\Windows\System32\convert.exe
The built-in windows commands always come first in the PATH.
Slightly off-topic to explain a similar problem: When people try to call MSYS find or sort or generic named commands like that within the Windows command line. Other commands like sed or grep work fine because they don't exist in MS-DOS, but Windows find or sort exist and come first, unless ran from MSYS2 shell (not to mention: the user's script miserably fail as the commands meaning & syntax are different)
As seen in the other comments, I suppose you're mixing up with compact command.
compact command is a compression program, very unlikely to efficiently pack your images. You really need the ImageMagik package. Irfanview is not a command-line tool but has a nice batch mode which works well.
So I have been working on a simple batch file, that thanks to #Magoo, I was able to solve the first question I had about it.
Now my next question,
Is there a way to automate an answer input.
Since I'm running Windows 7 (this is the current course I am on, in my quest to become a knowledgeable IT guy), I cannot use PowerShell to extract an image, and to my best knowledge, PowerISO is the only program I have found where I can use command lines in a batch file to extract the .iso file that I want, and place it on the drive/directory that I want. However, I came across the need to input an answer 'NoAll' before I could finish the extraction. I'm wondering if there is a way to automate that answer, if needed. It will only be used once, as the NoAll implies.
All the code is correct and the batch file works properly barring this one little hiccup.
Here's my batch file.
echo
cd "C:\Program Files\Windows AIK\Tools\PETools"
call copype amd64 "C:\winpe-amd64"
copy "C:\winpe-amd64\winpe.wim" "C:\winpe-amd64\iso\sources\boot.wim"
copy "C:\Program Files\Windows AIK\Tools\amd64\imagex.exe" "C:\winpe-amd64\iso" & cd "C:\Program Files\Windows AIK\Tools\amd64"
oscdimg.exe -n -bC:\winpe-amd64\etfsboot.com c:\winpe-amd64\iso c:\winpe-amd64\winpe-amd64.iso
cd 'C:\program files\powerISO"
piso extract "C:\winpe-amd64\winpe-amd64.iso" / -od f:
as the extract begins to run, I get a prompt for input, and this is where I would like to be able to automate the 'NoAll' answer.
Thanks in advance!
Since all you need to do it input text, you can simply echo what you want to type and then pipe it to the other command.
echo NoAll|piso extract "C:\winpe-amd64\winpe-amd64.iso" / -od f:
You can use the input file and input redirector '<' to automate most of input. For example, create a text file 'NoAll.txt' with the content "NoAll" (without quotes, and add a newline at the end for 'Enter' key). On the command that needs NoAll, execute it as follow:
piso extract "C:\winpe-amd64\winpe-amd64.iso" / -od f: < NoAll.txt
I am a Windows 7 User who wants to convert multiple *.eps files to pdf-files. Therefore I installed a program called EPSPDF.rb.
I integrated it into my systempath which makes me use it in the command prompt like this:
C:\TEMP>epspdf somefile.eps
The program converts somefile.eps to somefile.pdf.
What I am trying to achieve now is writing a Windows Batch File which will look in
the directory C:\TEMP for all *.eps files and convert them all.
I am still trying hard since I am quite unfamiliar with the programming language.
I guess writing the few lines will be an easy issue for someone who is familiar with Batch Files in Windows. I will be very grateful for any help!
for %%f in (*.eps) do epspfd %%f
This is for use in a batch file. You can run it right on the command prompt, only you need to use %f instead of %%f. Just because. ;)
for %F in (*.eps) do epspdf %F