Assume I have this structure:
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).
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
This is all you should need:
for /D %i in (*) do rename "%i" "%i1"
The /D performs the command against the directory names, as per the help, which can be obtained using the command for /?
If Command Extensions are enabled, the following additional forms of the FOR command are supported:
FOR /D %variable IN (set) DO command [command-parameters]
If set contains wildcards, then specifies to match against directory names instead of file names.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.