批处理命令:如果要是包含.PDF [英] Batch command: if IF contains .pdf

查看:211
本文介绍了批处理命令:如果要是包含.PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让批处理文件打印文件夹中的所有PDF文件。


  1. 我在 LIST.TXT 包含在文件夹中的所有文件(用 DIR / X )。


  2. 然后我用txt文件中的所有行,找到短文件名中的线(对 / F令牌= 4... ;例如: 12345678.pdf ; LIST.TXT


  3. 发送文件进行打印( AcroRd32.exe/ N / T%1)和重复#2。


的问题是,它需要的所有行(也未PDF)。是否有任何的可能性如何找到变量的一部分,然后用如果功能?
事情是这样的:

  IF%1==的* .pdf回声打印


解决方案

您现有的code只需要使用 DIR / X的* .pdf

不过,我会像下面这样替换整个code:

 为%% f由于(* .PDF)也开始,AcroRd32.exe / N / T%%〜snxF

I am trying to make batch file for printing all PDF files in folder.

  1. I made list.txt which contains all files in folder (with dir /x).

  2. Then I use all lines of the txt file and find "short filenames" in line (for /F "tokens=4" ... ; e.g. 12345678.pdf; list.txt).

  3. Send this file for printing ( AcroRd32.exe" /n /t "%1" ) and repeat #2.

The problem is that it takes all lines (also not PDF). Is any possibilities how to find part of variable and then use IF function? Something like this:

IF "%1" == "*.pdf" echo print

解决方案

Your existing code simply needs to use dir /x *.pdf.

But I would replace your entire code with something like the following:

for %%F in (*.pdf) do start "" AcroRd32.exe /n /t "%%~snxF"

这篇关于批处理命令:如果要是包含.PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆