Compare commits
2 Commits
b449ded8fe
...
d3648342e5
Author | SHA1 | Date | |
---|---|---|---|
d3648342e5 | |||
642edffcfe |
@ -1,9 +1,10 @@
|
|||||||
# Get each folder in the current directory
|
# Get each folder in the current directory
|
||||||
$folders = Get-ChildItem -Directory
|
$folders = Get-ChildItem -Directory
|
||||||
|
|
||||||
|
# Array to store the folders that need to be renamed
|
||||||
|
$work = @()
|
||||||
|
|
||||||
foreach ($folder in $folders) {
|
foreach ($folder in $folders) {
|
||||||
# Get each folder in the folder
|
|
||||||
$new_folders = Get-ChildItem -Path $folder.FullName -Directory
|
|
||||||
foreach ($folder in $new_folders) {
|
|
||||||
# Find the version number in the folder name
|
# Find the version number in the folder name
|
||||||
$version = $folder.Name -match '(\d+\.\d+\.\d+\.\d+)'
|
$version = $folder.Name -match '(\d+\.\d+\.\d+\.\d+)'
|
||||||
if ($version) {
|
if ($version) {
|
||||||
@ -16,9 +17,12 @@ foreach ($folder in $folders) {
|
|||||||
$new_name = $matches[1]
|
$new_name = $matches[1]
|
||||||
$new_name = $new_name + $matches[2]
|
$new_name = $new_name + $matches[2]
|
||||||
}
|
}
|
||||||
|
$toadd = New-Object PSObject
|
||||||
|
$toadd | Add-Member -MemberType NoteProperty -Name path -Value $folder.FullName
|
||||||
|
$toadd | Add-Member -MemberType NoteProperty -Name newname -Value $new_name
|
||||||
|
$work += $toadd
|
||||||
|
|
||||||
#Rename-Item -Path $folder.FullName -NewName $new_name
|
Write-Host "Rename $folder to $new_name"
|
||||||
Write-Host "Renamed $folder to $new_name"
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
# Find the version number in the folder name
|
# Find the version number in the folder name
|
||||||
@ -33,9 +37,12 @@ foreach ($folder in $folders) {
|
|||||||
$new_name = $matches[1]
|
$new_name = $matches[1]
|
||||||
$new_name = $new_name + $matches[2]
|
$new_name = $new_name + $matches[2]
|
||||||
}
|
}
|
||||||
|
$toadd = New-Object PSObject
|
||||||
|
$toadd | Add-Member -MemberType NoteProperty -Name path -Value $folder.FullName
|
||||||
|
$toadd | Add-Member -MemberType NoteProperty -Name newname -Value $new_name
|
||||||
|
$work += $toadd
|
||||||
|
|
||||||
#Rename-Item -Path $folder.FullName -NewName $new_name
|
Write-Host "Rename $folder to $new_name"
|
||||||
Write-Host "Renamed $folder to $new_name"
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
# Find the version number in the folder name
|
# Find the version number in the folder name
|
||||||
@ -50,10 +57,16 @@ foreach ($folder in $folders) {
|
|||||||
$new_name = $matches[1]
|
$new_name = $matches[1]
|
||||||
$new_name = $new_name + $matches[2]
|
$new_name = $new_name + $matches[2]
|
||||||
}
|
}
|
||||||
|
$toadd = New-Object PSObject
|
||||||
|
$toadd | Add-Member -MemberType NoteProperty -Name path -Value $folder.FullName
|
||||||
|
$toadd | Add-Member -MemberType NoteProperty -Name newname -Value $new_name
|
||||||
|
$work += $toadd
|
||||||
|
|
||||||
#Rename-Item -Path $folder.FullName -NewName $new_name
|
Write-Host "Rename $folder to $new_name"
|
||||||
Write-Host "Renamed $folder to $new_name"
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Read-Host -Prompt "Press Enter to continue"
|
||||||
|
foreach ($item in $work) {
|
||||||
|
Rename-Item -Path $item.path -NewName $item.newname
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user