Rename files problem
I came across this interesting problem and thought it was worth a post.
You have a folder with a set of files with names like this
Black or Blue .txt
Black or Green .txt
Black or White .txt
Black or Yellow [A2G345].txt
Blue or Green .txt
Pink or Yellow .txt
Purple or Gold .txt
Red or Blue .txt
Yellow or White .txt
You need to rename each file so that the  and stuff between them are removed.
Rename-Item won’t work because of the .
Read the file list with Get-ChildItem. Create the new name by splitting the Basename at the “[“ character and Trim any trailing blanks. Add the extension back on.
Use Move-Item to move the file to the same folder with a new name. The file is renamed.
I did try using the –split operator instead of split() but didn’t have any success