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.
for /fcommand usingdelims=-.set dirname="D:\SVN" && for /d "tokens=1,2 delims=- "%%G in ('dir /b %dirname%') do rename %dirname%\%%G-%%H %%Hwhere %%G is the string before delimiter and %%H is string after delimiter. But it gives me error like " in was unexpected at this time." .for /f, notfor /d. Also put a space between the double quote and %%G.set dirname=D:\SVN && for /f "tokens=1,2 delims=-" %G in (' dir /b %dirname%') do rename %dirname%\%G-%H-1 %H-1i getrename D:\SVN \Sample-2.2-1 2.2-1on the cmd. It means i get a space betweenrename D:\SVNand\Sample-2.2-1instead ofrename D:\SVN \Sample-2.2-1 2.2-1i getrename D:\SVN \Sample-2.2-1 2.2-1. If cmd is able to get command without space everything would be fine i guessren "%dirname%\%G-%H" "%H"