how to get pdftk to burst to source file name plus page number? - pdftk

How can I use pdftk to burst to the same filename as the source file plus a number?
Sample input
source.pdf
Desired output
source-1.pdf (it is ok if page number has leading zeroes, but not required)
source-2.pdf
Maybe I could use a .bat file to substitute the source filename? I have no idea how to do this. Any help at all is appreciated.

This can be done like the following:
pdftk source.pdf burst output source-%d.pdf

You have to wrap the pdftk command into a batch file. This should work:
#ECHO OFF
SETLOCAL
set file=%1
FOR %%i IN ("%file%") DO (
set prefix=%%~ni
)
set outname=%prefix%-%%02d.pdf
pdftk.exe %file% burst output %outname%

Install pdftk server version
Allow for adding the path to environment variables
This can be done like the following:
Open windows cmd prompt
pdftk source.pdf burst
or
pdftk source.pdf burst output -%d.pdf

Related

Command line will not run MAXScript

I have a command line code as follows -
for /r %%v in (*.max) do start %%v
It opens any Max file in the same folder - great.
I want it to also tell max to run any number of scripts when the file has opened, there are guides on how to do this on the 3dsMax help for eg:
-U MAXScript = (this will open MAXScript and run a certain script on the end of a fresh 3dsmax command load.
However this does not work on the end of the initial code I need to use.
I have been researching how this could work for 2 days but keep going in circles.
Please help.
Adam
try for /r %%v in (*.max) do START cmd.exe /C %%v
You might want to take a look at using 3dsmaxbatch.exe instead of 3dsmax.exe
Here is a link to the 2019 documentation:
https://knowledge.autodesk.com/support/3ds-max/learn-explore/caas/CloudHelp/cloudhelp/2019/ENU/3DSMax-Batch/files/GUID-48A78515-C24B-4E46-AC5F-884FBCF40D59-htm.html
The command line to load a max file then execute a script should look like this
3dsmaxbatch.exe -sceneFile C:/some/path/to/maxfile.max C:/some/path/to/script.ms

How to write STDOUT/STDIN via RedMon/cmd.exe to file?

I am trying to redirect a PS output to a file and process it further.
For this I am using the Printer Port Redirection RedMon which is sending the output to CMD.exe
C:\Windows\system32\cmd.exe
As arguments I expected that something like the following should work, but it does not. "%1" contains the user input for filename.
/c >"%1"
or
/c 1>"%1"
or
/c |"%1"
or
/c > "%1" 2>&1
What almost works if I send the output to a batch file which writes it then to file.
/c WriteOutput.bat "%1"
However, the batch file is somehow altering the file (skipping empty lines, and ignoring exclamation marks and so on...)
If possible I want to avoid a batch file. Is there a way to get it "directly" to a file?
Select "Print to FILE" in the printer options is not an option for me. I want the same end result but via cmd.exe being able to process it further.
Any ideas?
Edit:
Well, that's the batch file I used. It neglects empty lines and space at the beginning.
#echo off
setlocal
set FileName=%1
echo(>%FileName%.ps
for /F "tokens=*" %%A in ('more') do (
echo %%A>>%FileName%.ps
)
Well, so far I still haven't found a direct way to write STDIN via RedMon via CMD.exe to a file. As #aschipfl wrote, all the versions with for /F will skip lines and ignore certain characters.
However, with the following batch script (via RedMon) I end up with a "correct looking" file on disk.
C:\Windows\system32\cmd.exe /c WritePS.bat "%1"
"%1" contains the user input for filename without extension.
The Batch-File WritePS.bat looks as simple as this:
#echo off & setlocal
set FileName=%1.ps
more > "%FileName%"
However,
the resulting Postscript file is different from a file which I "Print to FILE" via the Postscript-Printer setup. I am pretty sure that all the printer settings which I can set are the same in both cases.
If anybody has an idea why there might be a difference, please let me know.

Merge txt file: TXTcollector

I am looking for an easy way (without windows commands) to merge several txt files.
Does anyone has an advice about the software TXTCollector? Is it a good one?
Thanks
A command prompt or .BAT/.CMD file can accomplish this easily by redirecting the output to a file.
type first.txt > merge.txt
type second.txt >> merge.txt
type third.txt >> merge.txt
A single redirection operator (e.g. >) will always create a new file with the output, overwriting any existing target file. Double redirection operators (e.g. >>) will append the output to an existing file or create a new file if one does not exist.
In the above .CMD script, the contents of first.txt, second.txt and third.txt will be in the new merge.txt.
EDIT Sample .CMD files
In its simplest form, a .CMD script that loops through the .txt files in a folder would look something like this.
#echo OFF
FOR %%c in (*.txt) DO TYPE %%c >> merge.txt
There is plenty of examples available on the web if you need to make adjustments for your particular situation.

How can I redirect the output of a command (running in a batch loop) to a file?

I have a windows batch file, which iterates over files in a folder and runs a command on each file. Specifically I am running xmllint to validate some files:
for %%i in (c:\temp\*.xml) do (
C:\XMLLINT\xmllint -noout -schema "C:\schemas\schema.xsd" "%%~dpnxi" >> c:\output.txt
)
It currently shows the output on screen. I want to show the output of all these commands placed in an output file. How can I achieve this? By using the append operator (>>) nothing is accomplished except for a blank file being created.
Is it because of xmllint?
If you're trying to redirect error output from the program, it might be writing to stderr. You can try to redirect it with:
for %%i in (c:\temp\*.xml) do (
C:\XMLLINT\xmllint -noout -schema "C:\schemas\schema.xsd" "%%~dpnxi" >> c:\output.txt 2>&1
)
Basically the 2>&1 at the end means redirect anything from stderr (which is 2) to stdout (which is 1). Since stdout is redirected to a file, you should now see the stderr stream in the file. Hope this works for you!
I've never used it, but if its documentation is here, have you tried just removing your "-noout" option, or adding an: "-output c:\output.txt"?

How can I write to the parallel port from the Windows Command line?

How can I write to parallel port through Windows XP command line?
Looking at your reply to Zoredache, your real problem is not output to the parallel port, that's trivial.
Your real problem is how to get a 0xff character on stdout. This is possible with a trivial .com executable which invokes the relevant soft interrupt, but to be honest it's probably easier to create a file with that single 0xff character in it and then just copy that to the printer:
> copy /b data.bin lpt1
Note the /b flag which tells copy that the file is a binary file.
Back in the DOS days we would frequently use a command like type filename.txt > lpt1 to print our text files.