This project has moved. For the latest updates, please go here.

Custom command AFTER rename/move?

Sep 11, 2013 at 8:18 PM
I've looked through the documentation and found mention of being able to run a custom command before processing; and after conversion but BEFORE the file is renamed. Is there no option to execute a command after the file has been renamed? I can probably pull off what I need to do using a directory watcher utility, but would rather not have yet another background app running on my HTPC. Is this possible but not documented, or just not possible yet? Thanks.
Coordinator
Sep 12, 2013 at 12:42 PM
Renaming is 2 steps:
1. Renaming the file in the temp directory
2. Moving it to the destination directory

What are you lookin to do?

Sep 12, 2013 at 2:15 PM
Edited Sep 12, 2013 at 2:16 PM
rboy1 wrote:
Renaming is 2 steps: 1. Renaming the file in the temp directory 2. Moving it to the destination directory What are you lookin to do?
For most shows, MCEBuddy as it is is fully sufficient for renaming an episode and placing it in the proper location/hierarchy for my Plex server to recognize it. But some shows are confusing to its TVDB scanner unless a series year is also specified--Castle, for instance. I have already written a small utility app that is run after any episode torrent that I download are complete, which, along with renaming the torrent file, will put it in a pre-existing series folder that also has a series year specified. For example, the file might wind up being renamed as 'Castle - S03E01.mkv', but because I already have a series folder called 'Castle (20090)', the app will place it in there and rename it to 'Castle (2009) - S03E01.mkv' instead of the generic 'Castle' series folder, allowing Plex to properly identify it. So, short version of the answer: I want to be able to call my app to do the final file renaming and moving. BUT, it doesn't have the smarts/connection to perform the metadata based renaming that MCEBuddy does. So it would have to be called AFTER MCEBuddy renamed the file.
Coordinator
Sep 13, 2013 at 1:45 AM
so here's a catch, if any programs moves or renames the file BEFORE it moves it from teh temp to the destination MCEBuddy will fail the conversion, basic sanity check.

So while your program cannot alter the file before it move, I can have mcebuddy be able to report to your program through custom command the final destination and name of the file just before it is moved and after it is renamed.


Sep 13, 2013 at 2:34 PM
rboy1 wrote:
so here's a catch, if any programs moves or renames the file BEFORE it moves it from teh temp to the destination MCEBuddy will fail the conversion, basic sanity check. So while your program cannot alter the file before it move, I can have mcebuddy be able to report to your program through custom command the final destination and name of the file just before it is moved and after it is renamed.
I would have no problem allowing MCEBuddy to do its normal renaming and moving operations, with an option to launch an app afterward. I would simply have MCEBuddy move to a staging folder where completed conversions will go prior to being moved by my app into their final resting place. That would work just fine. Thanks again.
Sep 13, 2013 at 8:29 PM
So I also use EventGhost in my setup and happened to accidentally stumble upon the fact that it has a directory watcher plug-in. I was able to do what I needed to do without adding another piece of background software to the chain of events. Thanks for entertaining the option--it would certainly save a step if MCEBuddy was able to call the app directly, but I have a working solution.
Coordinator
Sep 13, 2013 at 11:43 PM
When you mean call the app, I can add a custom command that will run POST the rename and moving the file, just like the one after the conversion. You can set it up to call your app from there with the necessary parameters. (with an option added for final name and directory)


Coordinator
Sep 14, 2013 at 9:57 PM
I've added support for PostCustomCommand, which runs AFTER the file has been renamed and moved to the final directory. So %convertedfile% will now point to the final moved converted file in this custom command.

also note I've slightly modified Custom Command, now this runs after the file has been renamed but BEFORE it is moved to the final destination, so now %convertedfile% now given the renamed file name and not the default converted file name.
Oct 23, 2013 at 7:31 PM
Edited Oct 23, 2013 at 7:33 PM
rboy1 wrote:
I've added support for PostCustomCommand, which runs AFTER the file has been renamed and moved to the final directory. So %convertedfile% will now point to the final moved converted file in this custom command.

also note I've slightly modified Custom Command, now this runs after the file has been renamed but BEFORE it is moved to the final destination, so now %convertedfile% now given the renamed file name and not the default converted file name.
I've finally gotten around to donating so I can try this out. It works great, but I've noticed a couple a things. The first is currently working as documented, but perhaps I can get you to rethink it. In my case, the PostCustomCommand is doing the legwork to do the final rename/move based upon specifics in my setup. Because it moves the file, MCEBuddy considers the conversion a failure and will not delete/archive the original file. I might suggest that, since at this point, MCEBuddy is technically done with the file, that it shouldn't care if PostCustomCommand deletes/renames/moves the final file.

The second is in regards to the command parameters. Per documentation, I've included double quotes where they need to be:
PostCustomCommandParameters="%convertedfile%" "D:\Media\TV Shows"
But MCEBuddy interprets the beginning and ending quotes as part of the data (from debug log):
PostCustomCommandParameters = D:\Media\Temp\_MCEBuddy\Marvel's Agents of S.H.I.E.L.D..S01E05.mkv" "D:\Media\TV Shows 
However if I enclose the WHOLE thing in quotes, it works fine. Again, this may be working as expected, or may be a bug:
PostCustomCommandParameters=""%convertedfile%" "D:\Media\TV Shows""
Thanks again for even going the extra mile to add this capability to MCEBuddy.
Coordinator
Oct 24, 2013 at 11:03 PM
you're correct, once the file has been converted and moved it's upto the user to do anything wtih it, so I've fixed it in the next build. it will log and error but continue as a success.

that design is correct, mcebuddy doesn't actually process hte quotes (this is just a display bug), it passes it onto the command prompt as it, so really the command prompt will interpret the quotes as desired. This was by design so that users (actually if you're using this feature, you're guru's and not users) can have complete control over the process. I've also documented this at the end of the documentation extensively, see if it doesn't make sense and let me know.
Oct 25, 2013 at 2:43 PM
Edited Oct 25, 2013 at 3:19 PM
rboy1 wrote:
you're correct, once the file has been converted and moved it's upto the user to do anything wtih it, so I've fixed it in the next build. it will log and error but continue as a success.

that design is correct, mcebuddy doesn't actually process hte quotes (this is just a display bug), it passes it onto the command prompt as it, so really the command prompt will interpret the quotes as desired. This was by design so that users (actually if you're using this feature, you're guru's and not users) can have complete control over the process. I've also documented this at the end of the documentation extensively, see if it doesn't make sense and let me know.
I think I may not have been clear enough in how I reported the issue. I read through the documentation on the custom commands (very much appreciated that you take the time to write good docs) and saw the example of using parameters with quotes:
e.g. CustomCommandParameters = /i "%convertedfile%" /o "%sourcefile%" -t
If I follow the example for my specific usage, it looks like
PostCustomCommandParameters="%convertedfile%" "D:\Media\TV Shows"
But the command line that is actually built is (for an example show):
D:\Media\Temp\_MCEBuddy\Marvel's Agents of S.H.I.E.L.D..S01E05.mkv" "D:\Media\TV Shows
Notice that the actual command line does NOT have the leading quote around the converted file name, nor the trailing quote after my second parameter. But if I enclose the WHOLE setting value in quotes (notice the extra set of quotes surrounding the full command line):
PostCustomCommandParameters=""%convertedfile%" "D:\Media\TV Shows""
The command line is built properly:
"D:\Media\Temp\_MCEBuddy\Marvel's Agents of S.H.I.E.L.D..S01E05.mkv" "D:\Media\TV Shows"
So, my guess is that MCEBuddy doesn't like the fact that my parameter list actually starts and ends with quotes; unlike the example in the documentation which does not start/end with quotes. Hopefully that explained what I am seeing with a bit more clarity. Thanks.
Coordinator
Oct 25, 2013 at 4:08 PM
to help me better grasp this can you post the exact lines you're using in profiles.conf


Oct 25, 2013 at 4:13 PM
rboy1 wrote:
to help me better grasp this can you post the exact lines you're using in profiles.conf
Sure thing. This is the way I had to do it in order to get the proper command line passed to my app:
PostCustomCommandPath=D:\Resources\TvTorrentMover.exe
PostCustomCommandParameters=""%convertedfile%" "D:\Media\TV Shows""
PostCustomCommandHangPeriod=0
PostCustomCommandCritical=false
This is the original way I tried, based upon the example in the documentation, that did not properly quote the command line parameters as I had expected:
PostCustomCommandPath=D:\Resources\TvTorrentMover.exe
PostCustomCommandParameters="%convertedfile%" "D:\Media\TV Shows"
PostCustomCommandHangPeriod=0
PostCustomCommandCritical=false
The difference is the extra set of quotes enclosing the entire parameter list in PostCustomCommandParameters.
Marked as answer by rboy1 on 1/29/2014 at 1:16 AM
Coordinator
Oct 25, 2013 at 6:06 PM
ah I see, okay there' not much I can do, since MCEBuddy use the INI file structure to read and write config file. The windows INI library does not read multiple quoted parameters hence you're facing the issue.


However the important question, what do you suggest I include in the documentation to clarify this functionality/quirk.


Oct 25, 2013 at 6:30 PM
rboy1 wrote:
ah I see, okay there' not much I can do, since MCEBuddy use the INI file structure to read and write config file. The windows INI library does not read multiple quoted parameters hence you're facing the issue. However the important question, what do you suggest I include in the documentation to clarify this functionality/quirk.
Perhaps something along the lines of, "If any of your parameters require quotes, as would often be the case for a file path, then you must also enclose the full CustomCommandParameters value in quotes." Hard to describe in just words, but an example as well would hopefully help explain it.
Coordinator
Oct 25, 2013 at 6:50 PM
:)) that's the trick, hence I asked. No matter, will try to document it thanks for reporting it


Coordinator
Oct 25, 2013 at 6:54 PM
actually you've run into a boundary condition.

Try this for customparameters:
/i "%convertedfile%" /o "%sourcefile%" -t

it work fine, no issue. The issue is if you command line starts with a quote and ends with a quote then you need to put double quotes around it :)


Marked as answer by rboy1 on 1/29/2014 at 1:15 AM