hozza
how to rename multiple folders
example:
I have folder C:\folder and inside of it i have sub folders: folder1, folder2, folder3 etc. and all of those folders inside is folder named v1.9.6 and iwant those folders renamed as v1.9.7
how to do it?
----------------------------
#2 29 Mar 2015 15:11
foxidrive
#3 29 Mar 2015 15:12
foxidrive
Your question is not very clear and this would help to understand it:
Use this command to get the folder structure in a text file - edit the file and paste a sample here of what you want to do.
dir /b /s /ad >file.txt
----------------------------
#4 29 Mar 2015 15:24
hozza
Structure:
C:\Folder\Folder1\v1.9.6\
C:\Folder\Folder2\v1.9.6\
C:\Folder\Folder3\v1.9.6\
C:\Folder\Folder4\v1.9.6\
C:\Folder\Folder5\v1.9.6\
and I want to rename all those v1.9.6 folders to v1.9.7
----------------------------
#5 29 Mar 2015 16:17
AiroNG
a very simple way would be:
Code: Select all
@echo off
setlocal enabledelayedexpansion
set "a="
for /l %%a in (1,1,5) do (
set "num=%%a"
pushd C:\Folder\folder!num!\
rename v1.9.6 v1.9.7
popd
)
goto :eof
I don't suffer from insanity, I enjoy every minute of it.
----------------------------
#6 29 Mar 2015 16:53
hozza
okey I wasnt very specific my mistake! folder names ain't a folder1 folder2.... etc.
here is the real one
Structure:
C:\Files\art\modifications\v1.9.6\
C:\Files\hangar\modifications\v1.9.6\
C:\Files\scripts\modifications\v1.9.6\
C:\Files\pictures\modifications\v1.9.6\
C:\Files\install_files\modifications\v1.9.6\
----------------------------
#7 29 Mar 2015 19:28
AiroNG
the long and not very smart way:
Code: Select all
@echo off
pushd C:\Files\art\modifications\
rename v1.9.6 v1.9.7
popd
pushd C:\Files\hangar\modifications\
rename v1.9.6 v1.9.7
popd
pushd C:\Files\scripts\modifications\
rename v1.9.6 v1.9.7
popd
pushd C:\Files\pictures\modifications\
rename v1.9.6 v1.9.7
popd
pushd C:\Files\install_files\modifications\
rename v1.9.6 v1.9.7
popd
Code: Select all
@echo off
for /D %%f in (C:\files\*) do (
rename %%f\modifications\v1.9.6 %%f\modifications\v1.9.7
)
goto :eof
for /d and a topic on stackoverflow
they might give you some pointers that will help you.
I don't suffer from insanity, I enjoy every minute of it.
----------------------------
#8 29 Mar 2015 23:11
Aacini
Try this:
Code: Select all
@echo off
for /D /R %%a in (C:\Files) do if "%~Na" equ "v1.9.6" ren "%%a" v1.9.7
#9 30 Mar 2015 08:08
hozza
I don't get it working only one i get working is that one by one line!Aacini wrote:
Try this:
Code: Select all
@echo off for /D /R %%a in (C:\Files) do if "%~Na" equ "v1.9.6" ren "%%a" v1.9.7
folders that have different names will need a wild card, and it messes that somehow because it is midlle of that structure!
----------------------------
#10 30 Mar 2015 08:47
foxidrive
Try this modification:
EDIT: I changed if "%%~nxa" to if /i "%%~nxa" to make the compare case insensitive too.
Code: Select all
@echo off
:begin
for /D /R "C:\Files" %%a in ("v1.9.6*") do if /i "%%~nxa"=="v1.9.6" ren "%%~a" "v1.9.7" & goto :begin
Last edited by foxidrive (30 Mar 2015 11:20)
----------------------------
#11 30 Mar 2015 10:16
hozza
foxidrive god damn you are genius!!!! that code was awesome, it's working like a charm!
thank you!!!
problem solved!
----------------------------
#12 30 Mar 2015 11:21
foxidrive
Beauty.hozza wrote:
it's working like a charm!
thank you!!!
problem solved!

Note that I made a change to the code above to cater for upper/lower case.