Jump to content

Automating Moving Movie Files into Folders


Recommended Posts

For anyone like me who started off creating their library of media and and deciding at a later date that maybe they want to move the those movies into their own folders, but don't want to manually create thousands of folders, and then manually move the files, you can automate that process with PowerShell (on WIndows). 

Open up a PowerShell prompt and navigate to the directory with your movies being stored, in my case on a network share. 

cd \\unraid\media\movies

Make sure this command will create a folder for every file in the directory you just navigated to. WARNING, I was lazy when I made this. This will technically create a folder for any object in the folder that has a period in the name. So, if for whatever reason, you already have folders with a period in the name, it will try to create a folder for it as well. If you already have a folder structure with periods, either don't use this or revise the command.

 

Get-ChildItem | Where-Object {$_.Name -Like "*.*"} | Select BaseName | ForEach-Object {New-Item -Name $_.BaseName -ItemType "Directory"}
 

This next command will actually move every item with a period in the name, into a folder of the same name, minus the file extension. So, if you have multiple copies of a movie, with multiple resolutions, or if you keep your metadata in NFO files, ALL of those files will be moved into the same folder.

Get-ChildItem | Where-Object {$_.Name -Like "*.*"} | ForEach-Object {Move-Item $_.Name $_.BaseName}

 

Link to post
Share on other sites
2 hours ago, Ulrichc said:

For anyone like me who started off creating their library of media and and deciding at a later date that maybe they want to move the those movies into their own folders, but don't want to manually create thousands of folders, and then manually move the files, you can automate that process with PowerShell (on WIndows). 

Open up a PowerShell prompt and navigate to the directory with your movies being stored, in my case on a network share. 

cd \\unraid\media\movies

Make sure this command will create a folder for every file in the directory you just navigated to. WARNING, I was lazy when I made this. This will technically create a folder for any object in the folder that has a period in the name. So, if for whatever reason, you already have folders with a period in the name, it will try to create a folder for it as well. If you already have a folder structure with periods, either don't use this or revise the command.

 

Get-ChildItem | Where-Object {$_.Name -Like "*.*"} | Select BaseName | ForEach-Object {New-Item -Name $_.BaseName -ItemType "Directory"}
 

This next command will actually move every item with a period in the name, into a folder of the same name, minus the file extension. So, if you have multiple copies of a movie, with multiple resolutions, or if you keep your metadata in NFO files, ALL of those files will be moved into the same folder.

Get-ChildItem | Where-Object {$_.Name -Like "*.*"} | ForEach-Object {Move-Item $_.Name $_.BaseName}

 

Very cool! Quick question, if someone didn't rename the original title, is there some way to get the correctly formatted title within the NFO file?

Link to post
Share on other sites
1 hour ago, qazwsx10 said:

Very cool! Quick question, if someone didn't rename the original title, is there some way to get the correctly formatted title within the NFO file?

You mean, using powershell to read the contents of an NFO file to rename a movie file? In theory yes. That isn't beyond reason, but coming up with some sort of scripted logic for discerning movie names that are for example, very similar, when they already have incorrect names sounds beyond my own skill.

Link to post
Share on other sites

I think I'd just use filebot to do this.  It could fix or update names of files along with creating proper folders along the way and wouldn't matter if folders exist or not already

Has both a GUI and command line mode.  Hard tool to top.

 

Link to post
Share on other sites
  • 5 months later...
pwhodges

s/schedule/scheduled/

They want to know if the recording location can be set per user. 

This question was asked earlier today or yesterday.  Someone suggested that any recording should have a choice of saving in the user's own folder or in a shared folder.

Paul

Edited by pwhodges
Link to post
Share on other sites
cayars

Thanks for the clarification Paul.

The answer to that question is NO a recording can't be set to record to specific locations based on users.
You could use a script you update to move content after recording to specific locations however.

The DVR has the ability to call a POST recording script when the recording is finished and this could be used for that purpose.

Link to post
Share on other sites

First time hearing about power shell. So, I learned something today.  Thanks..  What kind of scripting language do I need to look up in order to move the files over.  Is it more of bash file? 

 

Oh, I am the one that suggested saving videos in user's folders.  Also suggested creating a tag from the user when a video is made so you could filter it out. Probably work really good with a script.  If you knew the user then you could point to a folder for that user to move the files.

 

Another question, if you happen to know.  If you are watching live tv via Emby's web interface and you back out of it to goto Emby's setting etc, doesn't it release control of the tuner it was using?

Link to post
Share on other sites
PenkethBoy

If you look in the emby tools sub forum i created a how to with Post Processing using Powershell - its simple and would need enhancing to do what you need but it was done to give people a starting point

  • Like 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...