I’m having a headache trying to wrap my brain around this-

for my radio installers group, I have to rename roughly 25K folders from “[location] job site-date” to “job site-date [location]”

The folder name contains the same data, but literally I just have to reform the name to match the input filters for the job processor I’m stuck with.

I’m more than certain this is going to be a one liner, but trying this with regex is just making a mess.

10 Spice ups

I have a bulk rename utility that is so versatile that I cannot imagine it wouldn’t do what you need… the sad part is, it’s at home and I can’t recall the name of it. lol I’ll try to find from Google and let you know… but if I have to look when I get home, I’m sure you’ll have a solution by then…

2 Spice ups

This is the one I am thinking of… and I use.

Download link is on the left.

There are “append” and “prepend” type options that should do what you need…

When I first used this I thought it was complicated… and then looked for a different solution. Eventually I returned to this one and gave it some more thought and it’s the one I really like. What I wasn’t doing initially was actually selecting stuff in the “folder list window” to see what the effect of what I was changing at the bottom would have. Once I figured that part out, it made a lot more sense. I’m mentioning that hoping to save you some head scratches.

I use Renamer and it works well for me too.

EDIT: The preview feature is nice too because you can review the changes before they are made to make sure they look ok before pulling the trigger.

check the total commander - integrated multi renaming tool

http://tcup.eu/index.php?l=en

In any case does [Location] ever have a space in it? Trying to figure out how we can “know” what the location is?

But for the sake of a good example:

$Filename = "Boston 1234 12-06-2013"

$Name = $Filename.Split(" ")

$NewName = "$($Name[1]) $($Name[2]) $($Name[0])"
$NewName
2 Spice ups

After that it’s just a matter of setting up a loop in the parent directory and looping through the folder names.

No spaces in the location, but the location is always surrounded by . lemme try the code you just dropped

perfect for the naming- all I have to do is replace the spaces after location with underscores and it works exactly as I need. I can remove the underscores later

so, “[Aniak] Hope Tower-20091001” becomes “[Aniak] Hope_Tower-20091001” which then$NewName = “$($Name[1]) $($Name[0])” places as “Hope_Tower-20091001 [Aniak]” - then remove the underscores :slight_smile:

(unfortunately some of the job site names are pretty long- variable amount of spaces. easier to just rip them all out and treat it as one big word)

Thanks guys!

2 Spice ups

You could do it using just a few lines in powershell, provided you do the name of each location manually. Say your contents are the folder of D:\work:

$list = get-childitem D:\work | where Name -like ($location + "*")

foreach($item in $list){
$newitem = $item -replace $location, $null
$newitem = $newitem + " " + $location
Rename-Item -NewName $newitem -Path D:\work\$item}

Edit: Nevermind, Martin beat me to it with a better way of executing it than mine. Glad you got the help you needed! I really should refresh the page when I work on something else before coming back to contribute…

1 Spice up

You can avoid the messing around with underscores by changing your code just slightly. Instead of using the string Split method, use the -Split parameter. This allows you more control over how the split works, including the number of elements returned.

Thus,

$Name = "[Aniak] Hope Tower-20091001" -Split " ",2
"$($Name[1]) $($Name[0])"

Will return “Hope Tower-20091001 [Aniak]”

1 Spice up