Post Rename Reference
Post Rename Reference
Hi Rednoah
It's taken a while to figure it out but I've got your AMC script working as the part of a larger process. Pretty neat!
I'm wondering if there is a way to reference the file\ folder after AMC has renamed it?
Example: AMC sees the title from qbt using this reference "ut_title=%N", but "ut_title=%N" remains the original (old) title.
Thanks
Raptor6L
It's taken a while to figure it out but I've got your AMC script working as the part of a larger process. Pretty neat!
I'm wondering if there is a way to reference the file\ folder after AMC has renamed it?
Example: AMC sees the title from qbt using this reference "ut_title=%N", but "ut_title=%N" remains the original (old) title.
Thanks
Raptor6L
Re: Post Rename Reference
The -exec custom post-process commands manual is a good way to get started with custom post-process commands.
e.g.
{f} is the new file path
{historic.f} is the previous file path
{json} is the xattr metadata
"ut_title=%N" is notably not the file name / file path. %N typically refers to the download name which may or may not be the same as the actual file name / directory name. The ut_title variable is notably largely unused by the amc script but we do pass it along in all the examples because there's no reason not to. You can access that field from your format / exec / etc expression via the {defines.ut_title} binding.
e.g.
Shell: Select all
-exec /path/to/script.sh {f} {historic.f} {json}{historic.f} is the previous file path
{json} is the xattr metadata
Re: Post Rename Reference
Excellent, that I can have a play with.rednoah wrote: 30 May 2026, 07:07 The -exec custom post-process commands manual is a good way to get started with custom post-process commands.
e.g.{f} is the new file pathShell: Select all
-exec /path/to/script.sh {f} {historic.f} {json}
{historic.f} is the previous file path
{json} is the xattr metadata
Thank you again!
Re: Post Rename Reference
Hi RedNoah
Life's been busy but I've recently had time to come back to this. I can see the below command is now showing me the filepath in the logs:
I run your AMC script from a bash script and I'm trying to get that filepath back into my bash script.
Am I able to "Set" {quote f} to something like %newpath%, within your AMC script?
The idea being once your AMC script has finished, my bash script can continue on and use %newpath% when referring to that {quote f} filepath.
Hope that makes sense.
Thanks
Chris
Life's been busy but I've recently had time to come back to this. I can see the below command is now showing me the filepath in the logs:
Shell: Select all
filebot -script fn:amc ... --def exec="echo {quote f}"Am I able to "Set" {quote f} to something like %newpath%, within your AMC script?
The idea being once your AMC script has finished, my bash script can continue on and use %newpath% when referring to that {quote f} filepath.
Hope that makes sense.
Thanks
Chris
Re: Post Rename Reference
Raptor6L wrote: 01 Aug 2026, 00:51 I run your AMC script from a bash script and I'm trying to get that filepath back into my bash script.
e.g. (A) write output file paths to a file and then read that from your bash script after filebot is done:
Shell: Select all
filebot -script fn:amc ... --def exec="echo {quote f} >> /tmp/filebot.out"e.g. (B) parse the entire output of the filebot call directly from your bash script:
Shell: Select all
export FILEBOT_OUT=""
source <(
filebot -script fn:amc ... --def exec="echo 'export FILEBOT_OUT=\"\$FILEBOT_OUT{f}\\\\n\"'" | egrep "^export FILEBOT_OUT="
)
echo $FILEBOT_OUT
e.g. (C) make your -exec command do whatever you need to do instead of passing paths back to your bash script and then doing that:
Shell: Select all
filebot -script fn:amc ... --def exec="/path/to/script.sh {quote f}"Re: Post Rename Reference
Hi RedNoah
My file server is on a different system to the vm I'm running filebot on. My file server, for a few different reasons, is not up 24/7, but the vm that filebot is on is running 24/7.
I run filebot off a cmd script (apologies - i've referred to it as a bash script, when it actually isn't. It's a cmd script.) because not everything I run through the vm needs to go to filebot, so this cmd script filters out those files and redirects them where they need to go, and the rest goes to filebot.
For the files that do need to go to filebot, I've found that if my file server is not available (and therefore the --output location is not available) then the process fails and the file\folder does not get renamed and none of the metadata is gathered etc etc.
To combat this, I've got the --output location on the same vm as filebot. That way, even if the file server is down, filebot is still able to carry out all its duties.
What I'm trying to do here is get the new folder name and location so after filebot is done, the cmd script can trigger robocopy to move the folder to the fileserver location (if it's available). If that fails because the fileserver is down, that's fine, at least filebot has done its job.
The destination you used in your example above is /temp/filebot.out - no spaces so no need for quotes.
The destination I'm using is T:/FileBot/Logs/%title%.txt which stops once it comes to the first space within the title.
I've tried several methods including literal double quoting, or using a variant that results in double quoting:
This did exactly what it was supposed to, but as you can see, there are no spaces in the filename:
Have you got any suggestions on how to quote the txt file name?
Thanks
Chris
yeah, that's where my thoughts were leading to as well, but thought I'd ask anyway.AFAIK, a process called by your bash script (i.e. filebot) fundamentally cannot modify (i.e. write back variables) to the parent process.
So, first up, I'm fully aware my situation is not the norm - I'm probably in the 1% with the way I have my stuff set up, but it works for me nonetheless.What exactly do you need to do? Why pass information back to your bash script, instead of just acting on that information right when your --def exec command is called?
My file server is on a different system to the vm I'm running filebot on. My file server, for a few different reasons, is not up 24/7, but the vm that filebot is on is running 24/7.
I run filebot off a cmd script (apologies - i've referred to it as a bash script, when it actually isn't. It's a cmd script.) because not everything I run through the vm needs to go to filebot, so this cmd script filters out those files and redirects them where they need to go, and the rest goes to filebot.
For the files that do need to go to filebot, I've found that if my file server is not available (and therefore the --output location is not available) then the process fails and the file\folder does not get renamed and none of the metadata is gathered etc etc.
To combat this, I've got the --output location on the same vm as filebot. That way, even if the file server is down, filebot is still able to carry out all its duties.
What I'm trying to do here is get the new folder name and location so after filebot is done, the cmd script can trigger robocopy to move the folder to the fileserver location (if it's available). If that fails because the fileserver is down, that's fine, at least filebot has done its job.
This will work for me, except I'm having some troubles quoting the original title the echo is going to because it has spaces in it.e.g. (A) write output file paths to a file and then read that from your bash script after filebot is done:Shell: Select all
filebot -script fn:amc ... --def exec="echo {quote f} >> /tmp/filebot.out"
The destination you used in your example above is /temp/filebot.out - no spaces so no need for quotes.
The destination I'm using is T:/FileBot/Logs/%title%.txt which stops once it comes to the first space within the title.
I've tried several methods including literal double quoting, or using a variant that results in double quoting:
Using single quote marks instead of both being double, both ways:filebot -script fn:amc ... --def exec="echo {quote f} >> "T:/FileBot/Logs/%title%.txt""
filebot -script fn:amc ... --def exec="echo {quote f} >> 'T:/FileBot/Logs/%title%.txt'"
Using braces:filebot -script fn:amc ... --def exec='echo {quote f} >> "T:/FileBot/Logs/%title%.txt"'
With that last one I found the link to the arguments parsing in the forums, which led me to try using \ escapes:filebot -script fn:amc ... --def exec="echo {quote f} >> {T:/FileBot/Logs/%title%.txt}"
I then tried it with just a made up file name instead of the %title% variable to prove to myself it wasn't the variable:filebot -script fn:amc ... --def exec="echo {quote f} >> \"T:/FileBot/Logs/%title%.txt\""
Some of these didn't make a file at all. None of these made a .txt file. Some of them made a file but the file name stopped at the first space.filebot -script fn:amc ... --def exec="echo {quote f} >> \"T:/FileBot/Logs/A Made Up File Name (2018).txt\""
This did exactly what it was supposed to, but as you can see, there are no spaces in the filename:
The File.txt was created and it had the new folder and file location in it, which is almost perfect, except the txt file is not the same name as the original file name.filebot -script fn:amc ... --def exec="echo {quote f} >> T:/FileBot/Logs/File.txt"
Have you got any suggestions on how to quote the txt file name?
Thanks
Chris
Re: Post Rename Reference
Shell: Select all
filebot -script fn:amc ... --def exec="echo {quote f} >> T:/FileBot/Logs/File.txt"Shell: Select all
filebot -script fn:amc ... --def exec="echo {quote f} >> {quote defines.myLogFile}" --def myLogFile="T:/FileBot/Logs/%title%.txt"Shell: Select all
set "myLogFile=T:/FileBot/Logs/%title%.txt"
filebot -script fn:amc ... --def exec="echo {quote f} >> {quote System.env.myLogFile}"Re: Post Rename Reference
Haha, yep! It's the only bit of Windows left in my server environment. I'll no doubt make a move away from it at some point, but I'm not there yet.rednoah wrote: 05 Aug 2026, 05:35Your doing this on Windows!? With Windows CMD no less!? I don't usually use emoji... but...
In the meantime, I'll bask in the gentle glow of your rarely used emoji!
Ok, so I've tried this and it hasn't worked. I've actually tried several iterations. Some have created a file that wasn't a .txt file and it was named the first word of the title - so halted at the first space it came to. Others didn't create a file at all.rednoah wrote: 05 Aug 2026, 05:35Alright, lets say this work for you, so we can start with this:
Shell: Select all
filebot -script fn:amc ... --def exec="echo {quote f} >> T:/FileBot/Logs/File.txt"You also have a variable %title% in your CMD script context that you want to pass onto FileBot to be used as part of the --def exec command.
Rather than fighting CMD with a dynamically generated --def exec value, you could also just pass the value along via a generic --def name=value FileBot variable and then use that in your --exec expression:
Shell: Select all
filebot -script fn:amc ... --def exec="echo {quote f} >> {quote defines.myLogFile}" --def myLogFile="T:/FileBot/Logs/%title%.txt"
Title (and %title%) is Elizabeth The Golden Age (2007) [1080p]
--def exec="echo {quote f} >> {quote defines.myLogFile}" --def myLogFile="T:/FileBot/Logs/Elizabeth The Golden Age (2007).txt"
Both of these resulted in no file being created and the exact same entry in the log:--def exec="echo {quote f} >> {quote defines.myLogFile}" --def myLogFile="T:/FileBot/Logs/%title%.txt"
Another attempt but this time I used double quotations:Execute: echo @'
T:\FileBot\READY\Elizabeth The Golden Age (2007)\Elizabeth The Golden Age (2007).mp4
'@ >> @'
T:/FileBot/Logs/Elizabeth The Golden Age (2007) [1080p].txt
'@
out-file : Cannot perform operation because the wildcard path T:/FileBot/Logs/Elizabeth The Golden Age (2007) [1080p].txt
did not resolve to a file.
With this one, a file is created, but it isn't a .txt file, and it isn't the full name.--def exec="echo {quote f} >> {quote defines.myLogFile}" --def myLogFile=""T:/FileBot/Logs/%title%.txt""
Log entry:
So, it's falling over at the first space it comes to.Execute: echo @'
T:\FileBot\READY\Elizabeth The Golden Age (2007)\Elizabeth The Golden Age (2007).mp4
'@ >> @'
T:/FileBot/Logs/Elizabeth
'@
Interestingly, if I convert that file to a .txt, it has the correct info inside.
This time I put the space in the address rather than the file name. T:/File Bot/Logs instead of T:/FileBot/Logs:
Result is a file called "file" at T:/--def exec="echo {quote f} >> {quote defines.myLogFile}" --def myLogFile=""T:/File Bot/Logs/%title%.txt""
Any ideas?Execute: echo @'
T:\FileBot\READY\Elizabeth The Golden Age (2007)\Elizabeth The Golden Age (2007).mp4
'@ >> @'
T:/File
'@
Chris
Re: Post Rename Reference
Shell: Select all
filebot -script fn:amc ... --def exec="Add-Content -LiteralPath {quote defines.myLogFile} -Value {quote f}" --def myLogFile="T:/FileBot/Logs/%title%.txt"Re: Post Rename Reference
Winner winner chicken dinner!!!rednoah wrote: 05 Aug 2026, 10:14Looks like PowerShell doesn't like [...] in >> file paths...
Try this:
** using -LiteralPath instead of -Path is the key hereShell: Select all
filebot -script fn:amc ... --def exec="Add-Content -LiteralPath {quote defines.myLogFile} -Value {quote f}" --def myLogFile="T:/FileBot/Logs/%title%.txt"
Thanks RedNoah! Appreciate your time and efforts!