This is the solution I came up with, using PDFtk and a bit of cmd script.
It creates files in a sub folder called output, so make sure that exists before you try and run it.
<code>
@echo off
setlocal EnableDelayedExpansion
set "source=%~dp0"
set "name=%1"
IF DEFINED name (
call :burst %name%
) else (
call :usage
)
goto :xit
:burst
set "file=%~nx1"
echo Working on %file%
for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined mydate set mydate=%%x
SET "mytime=%mydate:~0,14%"
pdftk %name% burst output "%source%output\%file%_%mytime%_%%04d.pdf"
for %%d in (%source%output\doc_data.txt) do del %%d
echo Done!
goto :EOF
:usage
echo Nothing to do... drag a file onto me!
goto :EOF
:xit
endlocal
timeout /T 3
<\code>
2 comments:
I know this is an old post from 2015, but I found it today and using it to burst PDFs and it's working great, so thank you for this. But, is there anyway for it to pick up files with spaces in the name? For some reason, those files break the script.
Hi Justin, Sorry this is really late, and maybe you figured it out. I hadn't quoted the environmental variables, so it didn't like spaces. I've updated it now and test with a file that has spaces and it seemed to work... YMMV! :-)
Post a Comment