Renaming multiple subfolders in multiple folders at once

kimpossible1978

New member
Local time
7:16 AM
Messages
5
Location
Cape Town, South Africa
I need some help with renaming multiple subfolders in multiple folders quickly without having to download a program for assistance. So, I have ten folders on a shared drive, lets say named 2000 to 2010 for each year, each of those have 26 folders (one for each letter of the alphabet) then each of those have up to 100 folders and each of those have 6 subfolders.

all of these folders have already been named, there is one folder out of the 6 that needs to be renamed in every folder so its currently named excel, but needs to change to working file. Is there a command prompt I could use? Please don't tell me I have to do it manually folder by folder :huh::cry:
 

My Computer My Computer

At a glance

Windows 8 PRO 64bit3.20GHz8.00 GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell
OS
Windows 8 PRO 64bit
CPU
3.20GHz
Memory
8.00 GB
Antivirus
Macafee
Browser
IE
Hi,

So, I have ten folders on a shared drive, lets say named 2000 to 2010 for each year [...]
2000 to 2010 would actually represent eleven items, but I'm going to assume the folder names don't matter anyway.

From what I'm getting from your description, you want to rename folders named “excel” to “working file” that are exactly 3 subdirectories deep from the directory you say contains ten folders. If this is correct, you can easily do this through PowerShell...

Open a new PowerShell session and enter the following:
Code:
cd "[COLOR=gray]<the path of the directory that contains the ten folders here>[/COLOR]"
Then enter
Code:
dir -fi 'excel' -r | ?{(([uri]$_.FullName).Segments.Count - ([uri]$pwd.Path).Segments.Count) -eq 4} | %{$_.FullName}
Which will should list the folders you are trying to rename. This may take a while. If the output is correct, proceed to rename those folder using
Code:
dir -fi 'excel' -r | ?{(([uri]$_.FullName).Segments.Count - ([uri]$pwd.Path).Segments.Count) -eq 4} | %{ren $_.FullName 'working file'}



Please don't tell me I have to do it manually folder by folder
That would be daunting. 10*26*100 = 26000 would be a lot of folders to go through.
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Hi Pyrophly,
Really appreciate your response, unfortunately I do not have Powershell. I work in a corporate environment so our IT dept have blocked any ability to download anything :confused: yes doing this manually is a rather daunting job therefore I was hoping I could just use a command prompt type code (excuse misuse of programming language as I am no boffin) I am sure the code you provided would work perfectly, but yeah as mentioned I cannot access powershell.

Thanks for taking the time to help me I really appreciate it
 

My Computer My Computer

At a glance

Windows 8 PRO 64bit3.20GHz8.00 GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell
OS
Windows 8 PRO 64bit
CPU
3.20GHz
Memory
8.00 GB
Antivirus
Macafee
Browser
IE
Hi Pyrophly

Thanks for your response, I have inserted the code exactly as described up to the end of the 2nd line you'd sent, but I am not getting that list as you described, its just hanging? no error code or anything, just nothing happening? am I doing something wrong?
 

My Computer My Computer

At a glance

Windows 8 PRO 64bit3.20GHz8.00 GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell
OS
Windows 8 PRO 64bit
CPU
3.20GHz
Memory
8.00 GB
Antivirus
Macafee
Browser
IE
As there are many files, it may take a while before any output is displayed.

If the command completes (the prompt will reappear and you'll be able to type again) without any output, you'll have to explain to me again, with precise detail, the exact process you are trying to achieve. Please use examples where possible.
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
file renaming.JPG
I've attached a screenshot everything I've typed in up to the end of the first code. after that, as you mention, the command completes yes without any output. so I am unsure what exactly I have done incorrectly.

I have folders on a drive with years 2000 - 2010, in those folders I have subfolders A - Z, in each of those folders I have folders with clients beginning with A in A - Clients beginning with Z in Z. And in those folders are the subfolders incorrectly named excel and these need to be renamed to working papers. As you've previously mentioned yes its approximately 26 000 folders needing to be renamed which is extremely daunting.
 

My Computer My Computer

At a glance

Windows 8 PRO 64bit3.20GHz8.00 GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell
OS
Windows 8 PRO 64bit
CPU
3.20GHz
Memory
8.00 GB
Antivirus
Macafee
Browser
IE
Code:
cd "<S drive (\\ct04) (S:)>"
The above line is incorrect. “<S drive (\\ct04) (S:)>” is not a valid path name. I’m not sure why that didn't throw an error.

Try,
Code:
cd "S:\"
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Its unfortunately still doing nothing :( no output at all aaarrgghh sorry for wasting your time
 

My Computer My Computer

At a glance

Windows 8 PRO 64bit3.20GHz8.00 GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell
OS
Windows 8 PRO 64bit
CPU
3.20GHz
Memory
8.00 GB
Antivirus
Macafee
Browser
IE
Kimpossible1978, I have put together a replica of the folder structure you’ve described for me. Use this to test the commands on.

Download the zip file attached below, extract the contents to an empty folder, double-click and run the mapper.bat file which will create a mapping of the folder to a virtual drive ‘P:’ (I hope this letter isn't reserved for you). Open a PowerShell window and type cd "P:\". Now try the listing again.

Here’s another command line that should also list your ‘excel’ folder. Try it as well.
Code:
gci ('*\'*4) | ?{$_.Name -eq 'excel'} | %{$_.FullName}
 

Attachments

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Back
Top