Created
February 2, 2022 17:24
-
-
Save Gunslap/0473b530cb931977f98612234255ec87 to your computer and use it in GitHub Desktop.
Move All Files in a Folder to Subfolders (Handy for Radarr Movies)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$path = "V:\_Movies" #Path to scan | |
#Grab all files + folders in that path | |
$childItems = Get-ChildItem -Path $path -Force | |
#Loop through the child items | |
foreach($item in $childItems) | |
{ | |
#filter out directories | |
if($item.PSIsContainer -eq $false) | |
{ | |
$item.name | |
$folderName = $item.name.Substring(0,$item.name.length - $item.Extension.Length) | |
#Make a folder with the same name as the current file | |
New-Item -Path "$path\$folderName" -ItemType Directory -ErrorAction Ignore | |
#Move the file into the folder | |
Move-Item -LiteralPath $item.FullName -Destination "$path\$folderName\$item" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As long as subtitle files have the exact same name as the movie file (assuming that what you're using this for), it should be moved into the same directory.