This project has moved and is read-only. For the latest updates, please go here.

Archive doesn't work with the exact same name

Sep 13, 2016 at 7:05 PM
Example:
Folder C:/Watch is in the watchlist.

Inside this folder appears YYY.mkv. MCEBuddy will now transcode the file like configured to .mkv
However it only replaces the YYY.mkv with the new YYY.mkv, the original YYY.mkv won't get moved to the specified Backup/Archive folder.

Is this issue known?

If YYY.ts (so not the exact same name, other filetype) appears inside the folder, it works just fine. The old YYY.ts will be moved to the Archive folder and YYY.mkv is sitting in C:/Watch.
Sep 13, 2016 at 8:28 PM
Hmm yes that makes sense because the file is first converted (task 1) and then archived (task 2). In this case since Task 1 is overwriting the file (same name/location) with the exact same name it won't be able to archive it (Task 2). That's unfortunately an architectural limitation at this point.

Sep 13, 2016 at 8:39 PM
Edited Sep 13, 2016 at 8:39 PM
rboy1 wrote:
That's unfortunately an architectural limitation at this point.
Is it possible to create a workaround that adds something to the name before converting?
So for example:
YYY.mkv gets detected
rename to YYYBackup.mkv
conversion to resulting file YYY.mkv (Task 1)
old YYYBackup.mkv gets moved to Archive (Task 2)

Background:
Plex DVR's post-processing step needs the exact same name as before otherwise there are Metadata issues.
Sep 13, 2016 at 9:15 PM
Edited Sep 18, 2016 at 4:27 PM
What you can do a simple task, write a CustomCommand (which is run just after conversion but before the file is moved to the destination, see Advanced Commands documentation for details) which renames the original file and adds the words back to it.

Add this to your profile:
CustomCommandPath="c:\windows\system32\cmd.exe" 
CustomCommandParameters="/C ren "%sourcefile%" "%sourcefile%-Backup""
CustomCommandHangPeriod=60 
CustomCommandCritical=true
CustomCommandUISession=false
CustomCommandShowWindow=false
The command is marked critical so if it fails the conversion task will also fail and it won't overwrite your original file.
Sep 13, 2016 at 11:47 PM
Edited Sep 17, 2016 at 11:21 AM
Unfortunately it doesn't work. I can see that it says running Custom Commands in the GUI (so the lines are recognized in the profiles.conf) but nothing happens. It also doesn't result in a failed task, my original file still gets deleted.

Could there be a mistake in the second line?

edit:
I took a look at the logs and found the issue. "Backup-%sourcefile%" will put Backup before the path, and ofcourse this path doesn't exist, so I changed it to this:
CustomCommandParameters="/C ren "%sourcefile%" "%originalfilename%-Backup.mkv""
Finally, the file gets renamed! But then the file doesn't get moved.
Log says:
Error> ..... MCEBuddy.Engine.ConversionJob --> PreMeta Source file has been renamed or deleted by custom command
So I turned off the Archive and added a PostCustom command:
PostCustomCommandPath="C:\Windows\System32\cmd.exe" 
PostCustomCommandParameters="/c move /y "%destinationpath%\%originalfilename%-Backup.mkv" "D:\YYY\""
PostCustomCommandHangPeriod=30 
PostCustomCommandCritical=true
PostCustomCommandUISession=false
PostCustomCommandShowWindow=false
Sep 18, 2016 at 4:31 PM
Edited Sep 18, 2016 at 4:32 PM
You should be using CustomCommand not PostCustomCommand because the PostCustomCommand runs AFTER the converted file has been renamed and moved to destination folder (i.e. it has overwritten your original file). CustomCommand runs after the conversion but before the converted files has been renamed/moved to the destination.
Sep 18, 2016 at 4:41 PM
There may be something wrong with your custom command btw, you error says pre meta source file, your probably running a PreCustomCommand and not CustomCommand
CustomCommand only checks for converted file after execution and nothing else
Sep 20, 2016 at 6:26 PM
Edited Sep 20, 2016 at 6:40 PM
rboy1 wrote:
There may be something wrong with your custom command btw, you error says pre meta source file, your probably running a PreCustomCommand and not CustomCommand
CustomCommand only checks for converted file after execution and nothing else
Nope, I'm not using a PreCustomCommand.
CustomCommandPath="c:\windows\system32\cmd.exe" 
CustomCommandParameters="/C ren "%sourcefile%" "%originalfilename%-Backup.mkv""
CustomCommandHangPeriod=60 
CustomCommandCritical=true
CustomCommandUISession=false
CustomCommandShowWindow=false
Resulting Error:
Error> ..... MCEBuddy.Engine.ConversionJob --> PreMeta Source file has been renamed or deleted by custom command
Which makes sense because the archive function can't move a file which has been renamed from YYY.mkv to YYY-Backup.mkv. The archive function tries to move YYY.mkv which doesn't exist anymore because I have renamed it in the CustomCommand stage.

rboy1 wrote:
You should be using CustomCommand not PostCustomCommand because the PostCustomCommand runs AFTER the converted file has been renamed and moved to destination folder (i.e. it has overwritten your original file). CustomCommand runs after the conversion but before the converted files has been renamed/moved to the destination.
Why would it overwrite my original file when it has already been renamed?
Maybe I didn't make this clear, but currently my full code is this (with the archive turned off):
CustomCommandPath="c:\windows\system32\cmd.exe"
CustomCommandParameters="/C ren "%sourcefile%" "%originalfilename%-Backup.mkv""
CustomCommandHangPeriod=30
CustomCommandCritical=true
CustomCommandUISession=false
CustomCommandShowWindow=false
PostCustomCommandPath="C:\Windows\System32\cmd.exe"
PostCustomCommandParameters="/c move /y "%destinationpath%\%originalfilename%-Backup.mkv" "D:\YYY\""
PostCustomCommandHangPeriod=30
PostCustomCommandCritical=true
PostCustomCommandUISession=false
PostCustomCommandShowWindow=false
So it renames the Originalfile and then after everything is finished it moves the -Backup file to the location D:\YYY.

Do you mean in your above answers something like this would work (combines moving and renaming in the CustomCommand stage)?
CustomCommandPath="c:\windows\system32\cmd.exe"
CustomCommandParameters="/c move /y "%sourcefile%" "D:\YYY\%originalfilename%-Backup.mkv""
CustomCommandHangPeriod=30
CustomCommandCritical=true
CustomCommandUISession=false
CustomCommandShowWindow=false
I haven't tried it yet but it would make sense.
Either way the Archive function doesn't work and I have to manually set the backup path in the Profile.conf.

I hope a future version of MCEBuddy will fix this as it doesn't seem practical for the average user to edit the profiles.conf.
My guess is that once Plex DVR goes out of Beta you will have a pretty huge influx of users. So this should be a high priority to fix.
Sep 21, 2016 at 2:12 AM
Edited Sep 21, 2016 at 2:13 AM
Yes you got it, this should work just fine
CustomCommandPath="c:\windows\system32\cmd.exe"
CustomCommandParameters="/c move /y "%sourcefile%" "D:\YYY\%originalfilename%-Backup.mkv""
CustomCommandHangPeriod=900
CustomCommandCritical=true
CustomCommandUISession=false
CustomCommandShowWindow=false
I would increase the hang period if you're moving it across drives and its' a big file
Sep 21, 2016 at 2:37 AM
Edited Sep 21, 2016 at 2:39 AM
*rboy1 wrote:
I would increase the hang period if you're moving it across drives and its' a big file
Thanks, good idea. I'm currently using the same drive as the backup location so I haven't thought about that.

Can you say something about fixing the Archive function? If you don't want to touch the core "architecture" (like you said in the first reply) wouldn't it be easy to check whether the destination path is set to empty and the filetype before and after conversion is the same? And if both of those apply, use the user specified Archive folder in a "CustomCommand" automatically?
Sep 21, 2016 at 5:24 AM
We can look into it but it isn't going to be easy fix. No it isn't as easy because they're run from two different tasks, conversion and archiving are two different tasks, archiving runs after the conversion job is complete, what you're asking for will require interrupting one task, running a new task and then switching back to complete it.

Sep 21, 2016 at 9:50 AM
Edited Sep 21, 2016 at 9:51 AM
Doesn't by your own words CustomCommands run after the conversion job is complete as well? So where is the difference?
CustomCommand runs after the conversion but before the converted files has been renamed/moved to the destination.
Can't you just switch the sequence in general for all cases? First backup, then move converted file to the destination? What could be the drawback of that (actually curious)?
Jan 8 at 4:54 PM
I was having the exact same problem (files needed to have the same name due to Plex).

I get that this may be hard to change, but you may want to consider some kind of warning if the system won't work the way we may expect it to. From the settings, it seems like it would be something you could detect--archive set to yes, with no change to the filename/directory--and pop up a box. Or may include something in the tooltip text.

Seems to be working with the customcommand, but not very intuitive!

thx-
May 26 at 1:19 AM
Saw this thread posted in the plex DVR forum, any chance this custom command option could just be built in even if it's a checkbox in the gui, or a separate profile? it does seem a little odd do have to manually create a script for something that sounds similar to the archive function.