I am pretty new to powershell and have now read too many examples and fried my brain with Get-ChildItem examples.
I have a folder structure for my films as follows
Films
├─Film1
| Film1Name.mp4
│ └─Subs
│ └─English.SRT
│
├─Film2
| Film2Name.mp4
│ └─Subs
│ └─English.SRT
|
├─Film3
| Film3Name.mp4
│ └─Subs
│ └─English.SRT
What I am trying to achieve is to rename and move the *.srt file up a folder level and rename to either the filename of the film or the folder name of the film and insert .ENG to the .SRT filename before the extension. Then delete the unused 'Subs' folder, and do this recursively.
Ending up with the following based on the filename
├─Film1
| Film1Name.mp4
│ Film1Name.ENG.SRT
or this based on the folder name
├─Film1
| Film1.mp4
│ Film1.ENG.SRT
Any help would be most appreciated, either method would work
I was playing with this code from someone elses post and wiped out my test folder
$rootPath = "c:\Test"
Get-ChildItem -Path $rootPath -Directory | ForEach-Object {
$targetFolder = $_.FullName
Resolve-Path "$targetFolder\*" | ForEach-Object {
Move-Item -Path "$_\*.SRT" -Destination $targetFolder -Force
Remove-Item -Path $_
}
}