no way to find what i try (so simple):
i have this structure:
+folder1 (contains:)
-folder2
-folder3
-...
-folderi
I just want to add simple word (WORD) after the folders 2...i
simple ?
I shoul get:
-folder1WORD
-folder2WORD
-...
-folderiWORD
BUT i dont want to change folder1 name (i have succeed only to change ALL the folders)
BUT some of them have space in their name ( i have succeed to transform "folder with space" in 3 other ones folderWORD and withWORD and spaceWORD.
BUT should be a SPACE as first caracter of WORD (no way to make this)
right now i have try with what i found in the other threads without success !!!
Anyone get a way to do this ?
Thanks for your help.
Answer
If I'm understanding the question, then this will work for an interactive command prompt:
for /d %D IN (c:\temp\folder1\*.*) do ren "%D" "%~nxDWORD"
If you are running this inside a batch file, then you will need to double each of the percent signs:
for /d %%D IN (c:\temp\folder1\*.*) do ren "%%D" "%%~nxDWORD"
The /d
option tells for
to only look at directories. The ~nxD
modifier tells it to only print the filename and extension of D
rather than the full path. See FOR /?
for more information on the syntax of the modifiers.
Before
c:\temp\folder1>dir c:\temp\folder1
Directory of c:\temp\folder1
folder with space
folder.dotted
folder2
folder3
folderi
Command
c:\temp\folder1>for /d %D IN (c:\temp\folder1\*.*) do ren "%D" "%~nxDWORD"
c:\temp\folder1>ren "c:\temp\folder1\folder with space" "folder with spaceWORD"
c:\temp\folder1>ren "c:\temp\folder1\folder.dotted" "folder.dottedWORD"
c:\temp\folder1>ren "c:\temp\folder1\folder2" "folder2WORD"
c:\temp\folder1>ren "c:\temp\folder1\folder3" "folder3WORD"
c:\temp\folder1>ren "c:\temp\folder1\folderi" "folderiWORD"
Results
c:\temp\folder1>dir
Directory of c:\temp\folder1
folder with spaceWORD
folder.dottedWORD
folder2WORD
folder3WORD
folderiWORD
No comments:
Post a Comment