如何使用批处理命令列出硬盘上所有文件和文件夹?

huangapple go评论72阅读模式
英文:

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%
    )
    )

huangapple
  • 本文由 发表于 2023年4月17日 15:49:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76032808.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定