本帖最后由 ppll2030 于 2024-7-8 17:25 编辑
回复 16# qd2024
经过77大佬的提醒和指导,目前拖拽和粘贴复制的方式都没有问题了。- @echo off
- setlocal enabledelayedexpansion
- rem 注意::一定要保存为UTF-8格式的bat文件
- chcp 65001 >nul
- :start
- set f=%1
- if not defined f echo. &set /p f=添加PDF文件(拖拽文件或者填写文件的完整路径):
- if not defined f echo.&pause&cls&goto :start
- set f=%f:"=%
- for /f "delims=" %%i in ("%f%") do set _nf=%%~ni&set _xf=%%~xi&set _pf=%%~dpi
- set /a n=1
- cd /d %_pf%
- (for /f "delims=" %%a in ('type "标签.txt"') do (
- set str=%%a
- echo BookmarkBegin
- echo BookmarkTitle: !str!
- echo BookmarkLevel: 1
- echo BookmarkPageNumber: !n!
- set /a n+=1
- ))>bookmark.txt
- "%~dp0pdftk" "!f!" update_info_utf8 bookmark.txt output "!_nf!_bookmark!_xf!"
- rem 备份源文件,需要去掉前面两个 :: 冒号
- ::ren "!f!" "!_nf!_bak!_xf!"
- move /y "!_nf!_bookmark!_xf!" "!f!" >nul
- del /q bookmark.txt
- echo.&echo.书签添加完毕!&timeout /t 3&exit
复制代码
![](https://i.postimg.cc/yxbLTq9p/screenshots.gif) |