英文:
How to list all files and folders present in a hard disk using batch commands?
问题
我试图打印出硬盘不同分区中所有文件和文件夹的列表,使用以下代码:
for %d in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (ifexist %d: (dir %d:/s >> %Systeminfo_TXT%))
但是这没有输出任何内容?
我哪里错了!!
英文:
I am trying to print list of all the files and folders present in different partitions of hard disk using :
for %d in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (ifexist %d: (dir %d:/s >> %Systeminfo_TXT%))
but this doesn't print any output ?
Where am i going wrong !!
答案1
得分: 0
-
你定义了变量 %Systeminfo_TXT% 吗?
-
"ifexist" 命令在批处理文件中无效。您可以使用 "if" 命令以及 "exist" 操作符来检查驱动器是否存在。
for %%d in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%d: (
dir %%d:\ /s >> %Systeminfo_TXT%
)
)
英文:
-
Did you define the variable %Systeminfo_TXT%?
-
The "ifexist" command is not valid in batch files. Instead, you can
use the "if" command with the "exist" operator to check if a drive
exists.for %%d in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%d: (
dir %%d:\ /s >> %Systeminfo_TXT%
)
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论