使用批处理文件循环目录名称? [英] loop through directory names using a batch file?
本文介绍了使用批处理文件循环目录名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我具有以下结构:
d:/
-- /alpha/
-- /beta/
-- /gamma/
-- /delta/
我正在尝试执行一个通过这些文件夹的批处理文件(但不通过其中的子文件夹).
I'm trying to execute a batch file that goes through those folders (but not through sub-folders within them).
如何使用FOR LOOP获得此结果(假设我不知道文件夹的名称和数量):
How do I get this result using a FOR LOOP (assuming I don't know the name and quantity of the folders):
ren alpha alpha1
ren beta beta1
ren gamma gamma1
ren delta delta1
推荐答案
这就是您所需要的:
for /D %i in (*) do rename "%i" "%i1"
/D 根据帮助对目录名称执行命令,可以使用命令for /?
The /D performs the command against the directory names, as per the help, which can be obtained using the command for /?
如果启用了命令扩展,则以下的其他形式 支持FOR命令:
If Command Extensions are enabled, the following additional forms of the FOR command are supported:
FOR/D%IN输入变量(设置)DO命令[命令参数]
FOR /D %variable IN (set) DO command [command-parameters]
If set contains wildcards, then specifies to match against directory
names instead of file names.
这篇关于使用批处理文件循环目录名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文