使用批处理脚本仅打开文件夹中的非零文本文件 [英] Open only non-zero text files from a folder using batch script

查看:92
本文介绍了使用批处理脚本仅打开文件夹中的非零文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用批处理脚本打开目录中的所有文本文件(.txt),其中包含一些数据(大小不为0).

How to open all the text files (.txt) In a directory , which have some data in it (size not 0 ) using batch script.

谢谢.

推荐答案

for %%a in ("c:\folder\*.txt") do if %%~za gtr 0 start "" "%%~fa"

for命令将遍历与in子句匹配的文件.对于找到的每个文件,do子句中的代码都是参照存储在可替换参数(此示例中的%%a)中的文件执行的

The for command will iterate over the files matched by the in clause. For each file found, the code in the do clause is executed with a reference to the file stored in the replaceable parameter (%%a in this sample)

%%~za是文件的大小,%%~fa是具有完整路径的文件引用.因此,代码意味着:对于指定文件夹中的每个txt文件,如果文件大小大于0,请使用与其关联的任何应用程序启动文件

%%~za is the size of the file and %%~fa is the file reference with the full path. So, the code means: for each txt file in the indicated folder, if the size of the file is greater than 0, start the file with whatever application associated to it

注意:start命令将第一个带引号的参数作为启动窗口的标题.由于文件引用被引用以防止空格问题,因此包含了空引号,以避免将文件引用作为标题读取

note: start command takes the first quoted argument as the title of the started window. As the file reference is quoted to prevent problems with spaces, the empty quotes are included to avoid the file reference being readed as a title

这篇关于使用批处理脚本仅打开文件夹中的非零文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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