使用'for'循环迭代目录中的所有文件 [英] Iterate all files in a directory using a 'for' loop

查看:84
本文介绍了使用'for'循环迭代目录中的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用为 c>循环遍历目录中的每个文件?

How can I iterate over each file in a directory using a for loop?

推荐答案

这会列出所有文件(而且只有文件)在当前目录中:

This lists all the files (and only the files) in the current directory:

for /r %i in (*) do echo %i

此外,如果在批处理文件中运行该命令,您需要将%符号加倍。

Also if you run that command in a batch file you need to double the % signs.

for /r %%i in (*) do echo %%i

(感谢@agnul)

这篇关于使用'for'循环迭代目录中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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