下载pdftk http://bcn.bathome.net/s/tool/index.html?key=pdftk
- @echo off
- rem 保存为ansi编码
- cd /d "%~dp0"
- set "infolder=d:\a"
- set "outfolder=d:\b"
- set "file=d:\mulu.txt"
- set "_pdftk=d:\pdftk\pdftk.exe"
-
- (for /f "useback delims=" %%i in ("%file%") do (
- set /a n+=1
- setlocal
- call :gettime
- call echo %%t%% 开始处理第%%n%%行,文件夹名字为 %%i
- for /f "delims=" %%d in ('2^>nul dir /b /s /ad "%infolder%\%%i?"') do (
- if /i "%%i" equ "%%~nxd" (
- if not defined folder (
- set folder=1
- for /f "delims=" %%j in ('2^>nul dir /b /s /a-d "%%d\*.pdf"') do (
- set /a m+=1
- call set _"%%~nxj"%m%=%%j
- )
- for /f tokens^=3delims^=^" %%j in ('2^>nul set _') do (
- for /f "tokens=1* delims==" %%a in ("%%j") do (
- call set filelist=%%filelist%% "%%a"
- call echo %%t%% %%~nxa 已处理
- )
- )
- call :gettime
- if not defined filelist (
- call echo %%t%% 未完成处理,未找到文件
- ) else (
- call "%_pdftk%" %%filelist%% cat output "%outfolder%\%%i.pdf"
- call :gettime
- if exist "%outfolder%\%%i.pdf" (
- call echo %%t%% 完成处理,合并后的pdf名字为:%%i.pdf
- ) else (
- call echo %%t%% 未完成处理
- )
- )
- )
- )
- )
- if not defined folder (
- call :gettime
- call echo %%t%% 未完成处理,未找到文件夹 %%i
- )
- endlocal
- echo=
- )) > "log.log" 2>&1
- pause
- exit
-
- :gettime
- for /f %%a in ('wmic os get localdatetime ^| findstr [0-9]') do (
- set t=%%a
- )
- set t=%t:~0,4%年%t:~4,2%月%t:~6,2%日%t:~8,2%时%t:~10,2%分%t:~12,2%秒
- exit /b
复制代码
|