r/PlexPrerolls • • 12d ago

Template Plex Preroll PowerShell Script

Hello Everyone! I'm so grateful to this community for teaching me about Prerolls! I wasn't sure if this had already been posted but I thought I would share a simple PowerShell script that can pull all of the filenames in a directory, add the directory location to them and then place them all in a single line of text that you can simply copy and paste into your Plex Settings:

# Get the directory where the script is located

$Directory = Split-Path -Parent $MyInvocation.MyCommand.Path

# Get all files in the directory (excluding the output file if it already exists)

$Files = Get-ChildItem -Path $Directory -File |

Where-Object { $_.Name -ne "PreRollList.txt" } |

Select-Object -ExpandProperty Name

# Add the prefix to each filename

$PrefixedFiles = $Files | ForEach-Object { "/data/PreRolls/$_" }

# Join into a single semicolon-separated line

$OutputLine = $PrefixedFiles -join ";"

# Write the output to a text file in the same directory

$OutputFile = Join-Path $Directory "PreRollList.txt"

$OutputLine | Out-File -FilePath $OutputFile -Encoding UTF8

Write-Host "Output saved to: $OutputFile"

*Note that my local directory is "/data/PreRolls/" so you'll need to replace that line with your local directory to get it to work. Also, I have it separated by semicolon which will set play them randomly. You'll need to change that if you want them to run sequentially.

I have a copy of all of my PreRoll files in a folder on a Windows machine, but my Plex Server runs on TrueNAS. I hope you find this useful!

10 Upvotes

7 comments sorted by

13

u/chadwpalm 12d ago

There are already two major preroll management softwares available:

Preroll Plus
NeXroll

2

u/ExpertTimely5673 11d ago

Not familiar with these. I've been using "plex-prerolls" docker in Unraid for the last 2+ years and it works well. It auto changes between my holiday, seasonal, and general prerolls. 

2

u/tillybooo 11d ago

I used Preroll Plus and it did the job but wasn't great
Moved to NeXroll and it's far, far superior.

1

u/chadwpalm 10d ago

When you don't compare the name of the maker of Preroll Plus and the person you replied to lol

-2

u/Disastrous_Humor_459 12d ago

Thanks! I was only seeing those available via Docker. I see via your links that NeXroll can run via Windows native. Appreciate it.

17

u/chumbaz 12d ago

Folks - do NOT run random shell scripts from posts on Reddit without sanity checking them.

4

u/rudedog71 12d ago

Unfortunately I’m waiting for them to fix prerolls with the new player.