My task is to replace some characters in file names in about 10000 files I have including sub folders.
So in my example I want to change the character # to hash.
My file location is "C:\Users\JHB Laptop\Documents" with the main file called test "C:\Users\JHB Laptop\Documents\test".
Sub folders are "C:\Users\JHB Laptop\Documents\test\New folder1\New folder2\New folder3\New folder4\New folder5"
I adapted this code from user:331812 Malcolm
{cd "C:\Users\MyName\Documents\MyDirectory"
# by default, -replace is case-insensitive (equivalent to -ireplace)
# for case-sensitive, use -creplace
Dir | Rename-Item –NewName { $_.name –replace "_"," " }}
and this is my amendment:
cd "C:\Users\JHB Laptop\Documents\test"
by default, -replace is case-insensitive (equivalent to -ireplace)
for case-sensitive, use -creplace
Dir | Rename-Item –NewName { $_.name –replace "#","(hash)" }
This part works well but of course stops at the last folder in the string
And this is where my knowledge stops. I see that -recurse plays a part in sub folders, but I cannot work out where it fits in project.