Reputation: 137
I have 16 folders like:
Sample-2.1-1
Sample-2.2-1
Sample-2.3-1
.....
Sample-2.16-1
Those are inside a folder SVN for example
D:\SVN\Sample-2.1-1
D:\SVN\Sample-2.2-1
D:\SVN\Sample-2.3-1
.....
D:\SVN\Sample-2.16-1
Now I want to rename all these 16 folders by removing Sample-
in their names such as:
2.1-1
2.2-1
2.3-1
.....
2.16-1
How could I do it using for command inside cmd.
Upvotes: 0
Views: 263
Reputation: 130819
pushd "d:\svn"
for /f "tokens=1*" %%A in ('dir /b /ad sample-*') do ren "%%A-%%B" "%%B"
popd
Or, in the off chance that you have a folder name like sample--xxxx
, then
pushd "d:\svn"
for /d %%F in (sample-*) do for /f "tokens=1*" %%A in ("%%F") do ren "%%F" "%%B"
popd
Upvotes: 1