Replace characters in a file name with other characters

djchapple

Extraordinary Member
I have a large library of music file names (mp3 files) that I need to change to conform to certain criteria.

1. I need to append the two digits "00" to the beginning of certain filenames that do not have a track number
2. I need to replace the two characters "(a space)-", that may appear several times in different places, with a comma ","
3. I need to replace the first two digits (say 09 for instance) in certain file names (digits vary from file to file) with "09(space)-" (i.e I am effectively adding a space and a "-" after the track number

I have seen many examples where get-childitem is used in similar circumstances but I get lost with the bit at the end, that between the {}

So far it seems that I need to use - get-childitem -recurse | rename-item rename {???????????}

I am an experience user of Windows computers and OK with the use of the command line operations. However this command seems so complex and baffles me
 

Neemobeer

Principal Cybersecurity Architect
Staff member
What you're talking about using is Powershell, which is a full featured object oriented scripting language and yes it can be complicated and also mostly used by IT professionals to automate tasks.

Get-ChildItem cmdlet is what you would grab all files that you wanted to examine.
With all the files saved in an array you would then need to loop through them all and then very specifically determine which use case applies (probably with regex) and then transform the filename (string) and call Rename-Item
 
Top