You are not logged in.
Pages: 1
I have a Directory structure which looks like this :
Dir\SubDir1\SubDir2\SubDir3\Files
I would like to rename it as such:
Dir\SubDir1SubDir2\SubDir3\Files
So actually combining the names of SubDir1 and SubDir2
Is there a way to do that in cmd ?
Last edited by wquatan (11 Nov 2018 12:30)
Offline
Yes.
mkdir "Dir\SubDir1SubDir2"
move "Dir\SubDir1\SubDir2\SubDir3" "Dir\SubDir1SubDir2"
rmdir "Dir\SubDir1\SubDir2"
rmdir "Dir\SubDir1"
Offline
Hi,
That's the manual way which I knew of course.
My question was for an automatic way by getting Subdir1 and Subdir2 and creating Subdir1Subdir2 dynamically (and this for all existing Subdir1 / Subdir2 )
Offline
In fairness, you didn't actually express the full nature of your request -- the question as it was asked was answered. But it turns out that you asked the wrong question
Here's something to do what I think you're actually asking:
@echo off
for /d %%a in (Dir\*.*) do (
for /d %%b in (%%a\*.*) do (
move "%%~b" "%%~a%%~nxb"
rmdir "%%~a"
)
)
Last edited by bluesxman (13 Nov 2018 10:15)
cmd | *sh | ruby | chef
Offline
Pages: 1