You could use for to loop through each directory and rename it like so:
for /D %%f in (C:pathoWorkspace*) do rename "%%f" "%%~nxf_myname"
I tested this on Windows 7, but it should work at least as far back as with Windows XP.
What that does is this: for each directory in the path (within parenthesis), assign the directory name to the variable %%f
, then rename the directory %%f
to the name in the format you want (with your name attached). %%f
holds the full pathname, which is fine for the first argument to the rename
command, but for the second argument, we only want the filename+extension, thus the ~nx modifier prepended to our variable name.
By the way, when using this for
loop on the command line (rather than part of a batch file) you only want to use one % instead of %% for your variable name. E.g. for %f in...
instead of above.
See the following references from Microsoft for more details:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…