Folder Creation Script

It was suggested by a wise Plex user that I should move all of my movies to sub-folders within my main folder due to the sheer number that I have. Currently, I only have them in sub-folders if there are extras I have added.

Does anyone have a windows script that would take the title of my m4v files, create the folders and then move all of the files that match each folder name into their respective folder? It is going to take a long time to do it by hand and so I’m just looking to the collective knowledge of this fabulous community.

Thanks!!

can do it for you. And certainly many other renamer programs out there.

mp3tag or ‘Musicbrainz Picard’ can do it for music, btw.

@OttoKerner, you are the answer man for me today!! Now I just hope to be smart enough to figure it out!

This PowerShell script might do the job if you’re on Windows. It will ask you for the directory containing your movies and then it’ll ask for the file extension of the movies (mkv or mp4). For the directory, just drag the folder onto the console window. I have like no experience with Windows shell scripting, just so you know. I’m used to using Bash (or zsh) on Linux or Windows using Cygwin, which I use every day. Give it a try thought on a test folder. If it works, you can try it on your movies.

I use “File2Folder” downloaded from http://download.cnet.com/Files-2-Folder/3000-2248_4-75373366.html
Be careful and answer no to the crapware that the download link from CNet tries to install. Just install the File2Folder program.
It works well unfortunately it does not provide an “Undo” function.

I tried moving all my videos into folders and found it made adding new videos and maintaining my library a real mess and much more time consuming so I went to alphabetized directories (like #AB, CDE and so on) with sub-folders for a few movie groupings. I had to do that manually but it did not take too long. even though my library is about 3000 movies.

I really did not like the sub-folder for each movie approach. I do NOT find that what I am now using any slower at all than the excessive clutter approach and it is a LOT easier to maintain and keep current.

After trying it I cannot recommend separate folders for each movie except for extras, trailers and stuff and I really see no point in those things. For me they are just unnecessary clutter.

@JordanHarris, your script works great in the test that I have run. How would I add lines so I can move the cover art/fan art also? Basically, once the folder is created and the m4v file is moved, I need to move two specifically named jpg files as well, if they exist.

Before
M:\Movies\21 (2008).m4v
M:\Movies\21 (2008).jpg
M:\Movies\21 (2008)-fanart.jpg

After
M:\Movies\21 (2008)\21 (2008).m4v <-- Your script does this part already
M:\Movies\21 (2008)\21 (2008).jpg
M:\Movies\21 (2008)\21 (2008)-fanart.jpg

I should be able to do that in a little while. It’s a bit harder than I thought because I don’t know PowerShell at all, but the concept is easy. I might have to use a language I know better, like C++, and give you an executable that does it. For some reason, I’m having trouble matching part of file name with a part of another file name in PowerShell.

Thank you! No big rush! Feel free to use whatever language you feel comfortable in. I work with devs who use C++, Perl, and any number of languages.

No need to re-invent the wheel.
Here are some more alternatives to FileBot:



Disclaimer: I haven’t tested them and they might do only tv shows and not movies.

These are all great but I don’t need anything to rename my files to match correct formatting and file names. All of mine are named correctly and I know how to do that. I can put stuff in folders from now on. I’m just looking for a way to put all of the current files (movie and artwork) in their correct folders.

You can give this a try-its based on @JordanHarris 's work. it seemed to work in my limited testing. When it asks for a file extension enter * (wildcard) and if your naming convention is unwavering, this should work. Test it on your set up with a limited file folder. I tested two sets of files following your convention and it looked good. Remember- Homespun and no warranty.

I didn’t code for error checking

@grhiner - This worked exactly correct. I tested it with a folder that had 2 movie sets already in folders and one movie set with an m4v and just the single jpg (no fanart file) and the other was a mpg but had both jpg files. Everything was handled exactly as it should! Thank you so much!!!

Thank you for posting that @grhiner. I need to learn a little bit of PowerShell or batch scripting so I can write scripts that any Windows users can use. I personally do all my file handling using Cygwin with zsh (Z Shell). I even use it for things like encoding (FFmpeg), editing text (Vim), batch renaming for Plex (perl rename command), and pretty much any command line task. It’s a lot easier searching how to do something using bash or zsh, which will basically be the same solutions.

Why not use Ember Media Manager, it has a bulk rename and relocate and a GUI to manage everything?

forum.kodi.tv/forumdisplay.php?fid=195

I have been using it for about 4 years without issue.

My bulk rename pattern is as such:

folder pattern (for single movie in folder): $T ($Y)
folder pattern (for multiple movies in folder): $D - I DON’T USE THIS
File pattern: $T ($Y) - $R

What this gets me is: Movie (YEAR)\Movie (Year) - Resolution.ext

So Movies\Sleepers (1996)\Sleepers (1996) - 1080p.mkv

This will move all your fanart, posters, extras etc etc at the same time.

@rbeatse you are welcome. It was @JordanHarris that got the ball rolling. @JordanHarris it sounds like you are deep into scripting, I am a lazy sysadmin that realized PowerShell, C, C++ could do a lot of my Active Directory and Exchange work.

@grhiner I’m not really deep into scripting. I am however deep into programming and when I need to automate something, I’ll use Google to help me figure how to write a script. :wink: I could probably get things done faster using C++, but I need the practice with scripting anyways and it’s usually just 1 text file.

Not sure if you have already completed this but IMO, this is an unnecessary amount of work. I do agree with the suggestion that you recently received, but instead, change your directory structure to letter ranges. I recently did this because my files were stored the same as yours. The large number of files per folder is a pain when viewing the remote shares from a MAC and also ends up in a very long scan during a Plex library update.
I chose my letter ranges to even out the number of videos in my current movie folder. I actually placed all of my “T” titles movies in a separate folder since so many starts with ‘The’.

@sundi712 - there are several advantages besides pure speed (which I agree upon, so don’t take it too harshly) to have separate folders for each movie. It helps Plex do a better match and it enables you for instance to have local extras.

I am personally on the fringe of what Plex can handle (be forgiving enough about) because I let Filebot sort all my movies both in genre folder and a filenamefolder, ie, Movies\Action\Movie_name\Movie_name.mkv …

So, in short. Subfolders are good for keeping you and Plex sane - to a degree. To much (intricate such) might disturb Plex’s inner peace so thread carefully.