Hi,
So kind of an edge case here, but I'm trying to figure out if it's possible to use filebot functionality to either create a new empty folder or pass the rename value to a variable in powershell.
Basically i am using drivepool, which means the hardlinks functionality via filebot or radarr will not work. I've built a script that copies the files and creates hardlinks on the same volume as a workaround and that works well.
But I want to create that hardlink in the folder created by radarr and it would be much easier to use filebot to create that empty folder in my staging folders, create the hardlink inside it, and copy to final media folder, or alternatively just store the foldername filebot would rename with to a variable and then find that in the final media folder and create the hardlink there.
Basically i want to use filebot to use its ability to identify a movie or show and query against imdb or tmdb, create the string like "Movie (Year) tmdbid" and use that string elsewhere and not necessarily create or rename any existing folders.
For example, i could take that string and make a folder via powershell, recurse directories to see if it already exists, insert into a table, or whatever.
Sorry if I've not explained myself very well, anything not clear please just ask.
Create empty folder based on rename or pass to variable
Re: Create empty folder based on rename or pass to variable
You can provide your own shell script as --action parameter that can then do whatever with the target file path proposed by FileBot, on Linux and macOS at the very least. See Custom Rename Action › Shell Actions for details and examples.
You may need to use Custom Rename Action › Groovy Actions if you're using Windows though, since *.ps1 scripts are not native executable. IDK.
Keep us posted how you fare!

Keep us posted how you fare!
Re: Create empty folder based on rename or pass to variable
So I went a completely different route, this is just some sample code but it seems to work ok. I just use -action test and store the entire thing in a variable, and then parse out the folder name and file name into a custom psobject. It might be a little messy as I was originally pulling in all files in a directory and storing multiple folders and files in an array, but that just made it overly complex as I am already only processing one file at a time in my primary script.
Any full path to the media file can be passed to filebot, and then I use a fake output to R:\ as it's an unused drive letter in my case so there is less risk and it's easier to regex out.
Code: Select all
$filebotoutput = filebot -rename "D:\path\to\file.mkv" -non-strict --db TheMovieDB --output "R:/" --format '{n} ({y}) / {fn}' --action test
# Regex pattern to find lines starting with [TEST]
$Pattern = '^\[TEST\].*'
$MatchingLine = $null
# Split the text into lines
$Lines = $filebotoutput -split "`r`n"
# Iterate through lines and add matching lines to the array
foreach ($Line in $Lines) {
if ($Line -match $Pattern) {
$MatchingLine = $Line
}
}
# Output the matching lines
Write-Output "Line starting with [TEST]:"
Write-Output $MatchingLine
# Regex pattern to capture the value after [R:\ and before the next ]
$Pattern = '\[R:\\(.*?)\]'
# Extract the value
if ($MatchingLine -match $Pattern) {
$ExtractedValue = $Matches[1]
Write-Output "Extracted Value: $ExtractedValue"
} else {
Write-Output "No match found."
}
# Array to store the split values
$SplitValues = @()
# Split each line at the first backslash after the year
foreach ($Line in $ExtractedValue) {
$Parts = $Line -split '\\', 2
$SplitValues += [PSCustomObject]@{
FolderName = $Parts[0]
FileName = $Parts[1]
}
}
# Output the split values in table format
Write-Output "Split Values:"
$SplitValues | Format-Table -AutoSize
Write-Output "Folder Name: $($splitvalues[0].FolderName)"
#easy value for referencing folder name
#$splitvalues[0].FolderName
#easy value for referencing file name
#$splitvalues[0].FileName
Re: Create empty folder based on rename or pass to variable
Separate follow-up question, I know you are going to mention plex format but I'd like to see how to do this manually.
I found this thread which seems relevant but it's not very clear to me viewtopic.php?p=55915&hilit=use+brackets#p55915 and also this one viewtopic.php?p=63837&hilit=%7Bimdb#p63837
So right now, my path is '{n} ({y}) / {fn}'
But I want to add tmdbid, but not just the id, I want value like {tmdbid-tmdbidvalue} in the squiggly brackets, so my end result is MovieName (1999) {tmdbid-12345}
Of course just {tmdbid} works fine by itself, but I can't figure out the syntax and any escaping that might be necessary.
I found this thread which seems relevant but it's not very clear to me viewtopic.php?p=55915&hilit=use+brackets#p55915 and also this one viewtopic.php?p=63837&hilit=%7Bimdb#p63837
So right now, my path is '{n} ({y}) / {fn}'
But I want to add tmdbid, but not just the id, I want value like {tmdbid-tmdbidvalue} in the squiggly brackets, so my end result is MovieName (1999) {tmdbid-12345}
Of course just {tmdbid} works fine by itself, but I can't figure out the syntax and any escaping that might be necessary.
Re: Create empty folder based on rename or pass to variable


Format: Select all
{ " {tmdbid-$tmdbid}" }
