Batch - CMD file search

2019-05-21 14:35发布

I want to create a bat file that searches a specific folder for *.pdf files and executes the following two commands:

  1. C:\Program Files (x86)\Nitro PDF\Professional\NitroPDF.exe /CV "pdf-filename"

  2. move the file from C:\Users\ADMINI~1.MED\AppData\Local\Temp\1\pdf-filename to z:\

Any ideas?

I have written the following which returns the .pdf files:

FORFILES /P z:\ /M *.rtf /C "cmd /c echo @file"

2条回答
女痞
2楼-- · 2019-05-21 14:44

I think this will work both from the command line and from within a batch file

FORFILES /P z:\ /M *.rtf /C "cmd /c \"C:\Program Files (x86)\Nitro PDF\Professional\NitroPDF.exe\" /CV @PATH & MOVE C:\Users\ADMINI~1.MED\AppData\Local\Temp\1\@FILE Z:\"
查看更多
等我变得足够好
3楼-- · 2019-05-21 14:51

i think the easiest thing is to push the files resolved by "forfiles" to a second batch file... I tested it and show you my example (you only have to change "secondbat.bat to nitropdf and the second thing...).

C:\Users\keeny\test>dir


 Verzeichnis von C:\Users\keeny\test

03.01.2012  10:27    <DIR>          .
03.01.2012  10:27    <DIR>          ..
03.01.2012  10:28                10 secondbat.bat
03.01.2012  10:25                 0 test.txt
03.01.2012  10:25                 0 test2.txt
               3 Datei(en),             10 Bytes
               2 Verzeichnis(se), 67.541.872.640 Bytes frei

C:\Users\keeny\test>

then i typed

forfiles /P . /M *.txt /C "cmd /c secondbat.bat @file"

the secondbat gets its parameter by %1.

Content of secondbat.bat is only:

notepad %1

this test started 2 notepads...

I think this is it (please tell me if it worked the way you wanted to).

查看更多
登录 后发表回答