Forfiles 命令和 NitroPDF
Forfiles command and NitroPDF
我想使用 NitoPDF with a batch file, so, with this doc : Using Nitro via the command line
将一些文本文件转换为 PDF
我的批处理文件:
@echo off
Title Conversion des fichiers de type "*.txt" vers "*.pdf" by Hackoo 2016 avec NitroPDF
Mode con cols=130 lines=15 & color 0A
Set "NitroPDF=e:\Program Files\Nitro\Pro 10\NitroPDF.exe"
set "Source=%userprofile%\Desktop\SourceFolder"
set "Destination=C:\Users\Public\Documents\Pdf"
If not exist "%Destination%" MD "%Destination%"
echo \"%NitroPDF%\" & pause
::************************************************************************
:Conversion
FORFILES /P %source% /M *.txt /C "cmd /c \"%NitroPDF%\" /cv @PATH"
pause & exit
所以我得到了错误:`
'E:\Program' is not recognized as an internal control
or external, operable program or batch file.
我在这段代码之前使用了正常的 for
但问题是 NitroPDF.exe
在转换每个文件后没有关闭,所以,我必须手动关闭它才能在批处理文件中继续:
@echo off
Title Conversion des fichiers de type "*.txt" vers "*.pdf" by Hackoo 2016 avec NitroPDF
Mode con cols=130 lines=15 & color 0A
Set "NitroPDF=e:\Program Files\Nitro\Pro 10\NitroPDF.exe"
set "Source=%userprofile%\Desktop\VME_TRANSFERT"
set "Destination=C:\Users\Public\Documents\Pdf"
If not exist "%Destination%" MD "%Destination%"
::************************************************************************
:Conversion
FOR %%a IN ("%source%\*.txt") DO (
echo Conversion du fichier "%%a" vers "%%~na.pdf" ... & echo.
"%NitroPDF%" /cv "%%a"
rem Taskkill /IM "NitroPDF.exe" /F
Call :Deplacer
cls & echo.
)
rem Taskkill /IM "NitroPDF.exe" /F
pause & exit
::************************************************************************
:Deplacer
for %%f in ("%tmp%\*.pdf") do (
Move "%%f" "%Destination%\">nul 2>&1
)
goto:eof
::************************************************************************
在 ForFiles 中,双引号将被视为特殊字符,因此应替换为它的 HEX 等价物 0x22,未使用反斜杠转义。
FORFILES /P "%source%" /M *.txt /C "CMD /C START 0x220x22 0x22%NitroPDF%0x22 /cv @PATH"
我想使用 NitoPDF with a batch file, so, with this doc : Using Nitro via the command line
将一些文本文件转换为 PDF我的批处理文件:
@echo off
Title Conversion des fichiers de type "*.txt" vers "*.pdf" by Hackoo 2016 avec NitroPDF
Mode con cols=130 lines=15 & color 0A
Set "NitroPDF=e:\Program Files\Nitro\Pro 10\NitroPDF.exe"
set "Source=%userprofile%\Desktop\SourceFolder"
set "Destination=C:\Users\Public\Documents\Pdf"
If not exist "%Destination%" MD "%Destination%"
echo \"%NitroPDF%\" & pause
::************************************************************************
:Conversion
FORFILES /P %source% /M *.txt /C "cmd /c \"%NitroPDF%\" /cv @PATH"
pause & exit
所以我得到了错误:`
'E:\Program' is not recognized as an internal control or external, operable program or batch file.
我在这段代码之前使用了正常的 for
但问题是 NitroPDF.exe
在转换每个文件后没有关闭,所以,我必须手动关闭它才能在批处理文件中继续:
@echo off
Title Conversion des fichiers de type "*.txt" vers "*.pdf" by Hackoo 2016 avec NitroPDF
Mode con cols=130 lines=15 & color 0A
Set "NitroPDF=e:\Program Files\Nitro\Pro 10\NitroPDF.exe"
set "Source=%userprofile%\Desktop\VME_TRANSFERT"
set "Destination=C:\Users\Public\Documents\Pdf"
If not exist "%Destination%" MD "%Destination%"
::************************************************************************
:Conversion
FOR %%a IN ("%source%\*.txt") DO (
echo Conversion du fichier "%%a" vers "%%~na.pdf" ... & echo.
"%NitroPDF%" /cv "%%a"
rem Taskkill /IM "NitroPDF.exe" /F
Call :Deplacer
cls & echo.
)
rem Taskkill /IM "NitroPDF.exe" /F
pause & exit
::************************************************************************
:Deplacer
for %%f in ("%tmp%\*.pdf") do (
Move "%%f" "%Destination%\">nul 2>&1
)
goto:eof
::************************************************************************
在 ForFiles 中,双引号将被视为特殊字符,因此应替换为它的 HEX 等价物 0x22,未使用反斜杠转义。
FORFILES /P "%source%" /M *.txt /C "CMD /C START 0x220x22 0x22%NitroPDF%0x22 /cv @PATH"