|
(defun K:MPDF4Folder (OriPatch TgtPatch PreNam / TKPath PDFNam FlieNam BatFile)
(if
(and
(setq TKPath (findfile "pdftk.exe"));如果Pdftk存在
(vl-file-directory-p OriPatch);源文件夹存在
(vl-file-directory-p TgtPatch);目标文件夹存在
(vl-directory-files OriPatch "*.PDF" 1);源文件夹存在PDF
(setq PDFNam (strcat PreNam "-合并.pdf"));合并后的文件名
)
(progn
(if (findfile (strcat TgtPatch PDFNam))(vl-file-delete (strcat TgtPatch PDFNam)));删除旧PDF
(setq FlieNam (vl-filename-mktemp "PDF合并" nil ".BAT"))
(setq BatFile (open FlieNam "w"))
(Write-Line (strcat
"start /min \"\" "
TKPath
" "
OriPatch ;源文件路径"%cd%\\
"*.pdf"
" cat output "
TgtPatch ;储存文件路径%cd%\\
PDFNam ;文件名
)
BatFile
)
(close BatFile)
(command "Shell" FlieNam "");运行BAT
(if (findfile (strcat TgtPatch PDFNam))(vl-file-delete FlieNam));删除BAT
(vlax-invoke-method (vlax-create-object "Shell.Application") 'Open TgtPatch)
)
(if (vl-file-directory-p OriPatch)
(vlax-invoke-method (vlax-create-object "Shell.Application") 'Open OriPatch)
)
)
)
参考用法:
(setq DwgPath (getvar 'DWGPREFIX))
(setq FolderPath (strcat DwgPath "--PDF--\\"))
(K:MPDF4Folder DwgPath FolderPath (vl-filename-base (getvar 'DwgName)))
|
|