# Custom command failing

**URL:** https://discussion.mcebuddy2x.com/t/custom-command-failing/329
**Category:** Custom Commands
**Created:** [July 28, 2017, 8:42pm UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329 "2017-07-28T20:42:19Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Robert](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://discussion.mcebuddy2x.com/u/Robert)
#### Post date: [July 28, 2017, 8:42pm UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/1 "2017-07-28T20:42:19Z")

</div>

I’m not sure what triggered this, and OS update or an MCEB update, but in build .7 and .8 converted files are no longer being moved to my network drive.

This has been working for years, so I’m not sure what I did to mess things up.

As usual I have updated the service with an administrator account user. I’ve also tried adding same user to the Network Authentication settings in the UI under settings.

I noticed this in the conversion log, but I don’t understand why as there are no Illegal characters in the path.

> E:\VideoCaptures\Cleaned Files\Zoo Drop It Like Its Hot s03 e05 07-27-2017.ts

> INFORMATION\> 2017-07-28T16:15:09 MCEBuddy.Engine.ConversionJob → Running [custom commands](https://discussion.mcebuddy2x.com/t/mcebuddy-advanced-settings-commands-and-tweaking/30#customcommands)  
> → Custom Renaming Command → %showname% %episodename% s%season%## e%episode%## %airmonth%-%airday%-%airyear% %rating%  
> WARNING\> → Cannot find Parental Rating  
> 2017-07-28T16:15:09 MCEBuddy.Transcode.CustomCommand → [Custom command](https://discussion.mcebuddy2x.com/t/mcebuddy-advanced-settings-commands-and-tweaking/30#customcommands) parameters read →   
> PostCustomCommandPath = “e:\videocaptures\cleaned files\mcebpostprocess.bat”  
> PostCustomCommandParameters = “%convertedfile%” %sourcefile% “%destinationpath%” 1080 .%convertedext% 0 %airmonth% %airday% %airyear% %season%##  
> PostCustomCommandHangPeriod = 0  
> PostCustomCommandCritical = False  
> PostCustomCommandUISession = False  
> PostCustomCommandShowWindow = True  
> PostCustomCommandExitCodeCheck = False  
> ERROR\> 2017-07-28T16:15:09 MCEBuddy.Engine.ConversionJob → Unhanded error during conversion, conversion cancelled  
> System.ArgumentException: Illegal characters in path.  
> at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)  
> at System.IO.Path.IsPathRooted(String path)  
> at MCEBuddy.Transcode.CustomCommand.Run()  
> at MCEBuddy.Engine.ConversionJob.Convert()  
> INFORMATION\> 2017-07-28T16:15:09 MCEBuddy.Engine.ConversionJob →   
> → Performance Metrics for the Current Conversion  
> →

I [uploaded the both logs](https://discussion.mcebuddy2x.com/t/5076) to the FTP server.

---

<div class="post-metadata">

### Author: ![RBoy](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@RBoy](https://discussion.mcebuddy2x.com/u/RBoy)
#### Post date: [August 1, 2017, 12:04am UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/2 "2017-08-01T00:04:09Z")

</div>

That’s because your [custom command](https://discussion.mcebuddy2x.com/t/mcebuddy-advanced-settings-commands-and-tweaking/30#customcommands) is generating an invalid command:

> PostCustomCommandPath = “e:\videocaptures\cleaned files\mcebpostprocess.bat”  
> PostCustomCommandParameters = “%convertedfile%” %sourcefile% “%destinationpath%” 1080 .%convertedext% 0 %airmonth% %airday% %airyear% %season%##  
> PostCustomCommandHangPeriod = 0  
> PostCustomCommandCritical = False  
> PostCustomCommandUISession = False  
> PostCustomCommandShowWindow = True  
> PostCustomCommandExitCodeCheck = False  
> ERROR\> 2017-07-28T16:15:09 MCEBuddy.Engine.ConversionJob → Unhanded error during conversion, conversion cancelled  
> System.ArgumentException: **_Illegal characters in path._**  
> at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)  
> at System.IO.Path.IsPathRooted(String path)  
> at MCEBuddy.Transcode.CustomCommand.Run()  
> at MCEBuddy.Engine.ConversionJob.Convert()

Your [custom command](https://discussion.mcebuddy2x.com/t/mcebuddy-advanced-settings-commands-and-tweaking/30#customcommands) is generating invalid path characters for your command batch file.

---

<div class="post-metadata">

### Author: ![Robert](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://discussion.mcebuddy2x.com/u/Robert)
#### Post date: [August 1, 2017, 10:29am UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/3 "2017-08-01T10:29:21Z")

</div>

Hmmmm Did something change in build .7 (.8), or did I screw something up? (I didn’t knowingly make any changes) I’ve looked though my systems backup’s went back 30 days and I don’t see any changes in anything below.

Here is the command string as presented in the profile

> PostCustomCommandPath=“E:\VideoCaptures\Cleaned Files\MCEBPostProcess.bat”  
> PostCustomCommandParameters=“%convertedfile%” %sourcefile% “%destinationpath%” 1080 .%convertedext% 0 %airmonth% %airday% %airyear% %season%##  
> PostCustomCommandHangPeriod=0  
> PostCustomCommandCritical=false

Here is the called .bat file:

> @ECHO OFF

> setlocal EnableDelayedExpansion

> SET BatFile=“E:\VideoCaptures\Cleaned Files\TVTransfer.bat”  
> SET OutputFileName=“%~n1”  
> SET InputFileName=“%~n2”  
> SET FolderOutput=“%~3”  
> SET WideoWidth=“%~4”  
> SET OutputExtension=“%~5”  
> SET OutputFileSize=“%~z1”  
> SET OADMonth=“%~7”  
> SET OADDay=“%~8”  
> SET OADYear=“%~9”  
> SHIFT /4  
> SET SEASON=%~9  
> Call %BatFile% %OutputFileName% %InputFileName% %FolderOutput% %WideoWidth% %OutputExtension% %OutputFileSize% %OADMonth% %OADDay% %OADYear% %SEASON%

Here is the .bat file where all the work is done.

> @ECHO ON  
> setlocal EnableDelayedExpansion

> SET sPAT=“\SERVER\Recorded TV\Other Shows”  
> SET OUTPUT\_NAME=“%~1”  
> SET INPUT\_NAME=%~2  
> SET OUTPUT\_FOLDER=%~3  
> SET VIEDO\_WIDTH=%~4  
> SET OUTPUT\_Ext=%~5  
> SET OUTPUT\_FILE\_SIZE\_MB=%~6  
> SET OAD\_MONTH=%~7  
> SET OAD\_DAY=%~8  
> SET OAD\_YEAR=%~9  
> SHIFT /4  
> SET SEASON=%~9  
> SET SEARCHNAME=
> 
> If “%OAD\_MONTH%” == “” (  
> SET OAD\_MONTH=NA  
> )  
> If “%OAD\_DAY%” == “” (  
> SET OAD\_MONTH=NA  
> )  
> If “%OAD\_YEAR%” == “” (  
> SET OAD\_MONTH=NA  
> )  
> If “%SEASON%” == “” (  
> SET SEASON=NA  
> )
> 
> echo.%OAD\_MONTH%  
> echo.%OUTPUT\_FILE\_SIZE\_MB%
> 
> ::Todays Date  
> FOR %%A IN (%Date%) DO (  
> FOR /F “tokens=1-3 delims=/-” %%B in (“%%~A”) DO (  
> SET MMDDYYYY=%%B-%%C-%%D  
> )  
> )

> If %OAD\_MONTH% NEQ NA (  
> SET MMDDYYYY=%OAD\_MONTH%-%OAD\_DAY%-%OAD\_YEAR%  
> )
> 
> echo.%MMDDYYYY%

> :: Only procc. the video files, otherwise just delete  
> If %OUTPUT\_FILE\_SIZE\_MB% LEQ 200000000 (  
> DEL /q “%OUTPUT\_FOLDER%%~1%OUTPUT\_Ext%”  
> EXIT  
> )

> ::Remove any Spaces from Search Name  
> set HAYSTACK=%INPUT\_NAME%  
> set HAYSTACK=%HAYSTACK: =%

> echo.%HAYSTACK%

> :: Grab the string before the first “-”.  
> for /f “delims=-” %%i in (“%HAYSTACK%”) do set string=%%i  
> SET SEARCHNAME=%string%

> echo.%SEARCHNAME%

> :: Get the Show Params  
> for /f “tokens=2-3 delims=;” %%A in (‘findstr /b /i “%SEARCHNAME%” “C:\FTPSyncFiles\Bat Files\SHOWPARMS.txt”’) do (

> SET sPAT=%%A  
> )

> echo This is the program path %sPAT%

> :: Copy to the Server  
> If %sPAT% NEQ “” (
> 
> IF %SEASON% NEQ NA (  
> :: Check to see if Dir exist already  
> if NOT EXIST %sPAT%\SEASON-%SEASON% (  
> MD %sPAT%\SEASON-%SEASON%  
> )  
> :: Removed the use of OUTPUT\_NAME becuase of special charictors and used %~1 (Which removes the quotes) instead  
> START “MCE Move” /b cmd /c move /y “%OUTPUT\_FOLDER%%~1%OUTPUT\_Ext%” %sPAT%\SEASON-%SEASON%   
> :: Update the root directory with the current date using Touch.exe  
> touch -m %sPAT%  
> ) ELSE (  
> :: Check to see if Dir exist already  
> if NOT EXIST %sPAT%%MMDDYYYY% (  
> MD %sPAT%%MMDDYYYY%  
> )  
> :: Removed the use of OUTPUT\_NAME becuase of special charictors and used %~1 (Which removes the quotes) instead  
> START “MCE Move” /b cmd /c move /y “%OUTPUT\_FOLDER%%~1%OUTPUT\_Ext%” %sPAT%%MMDDYYYY%  
> :: Update the root directory with the current date using Touch.exe  
> touch -m %sPAT%  
> )
> 
> :: Delete the .properties files if present  
> DEL /q “E:\VideoCaptures\QSF%INPUT\_NAME%.ts.properties”  
> DEL /q “E:\VideoCaptures\QSF%INPUT\_NAME%.mpg.properties”  
> )

---

<div class="post-metadata">

### Author: ![RBoy](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@RBoy](https://discussion.mcebuddy2x.com/u/RBoy)
#### Post date: [August 1, 2017, 8:33pm UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/4 "2017-08-01T20:33:51Z")

</div>

Start by printing the variables being passed to your custom command. The variables come from your metadata. Looks at your logs to see what metadata is being passed to MCEBuddy and you’ll have your answer why there’s an illegal character in your path somewhere.

---

<div class="post-metadata">

### Author: ![Robert](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://discussion.mcebuddy2x.com/u/Robert)
#### Post date: [August 2, 2017, 12:37am UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/5 "2017-08-02T00:37:40Z")

</div>

How do I view the variables being passed by MCE in .7 or .8? Older versions would log the output from MCE on a debug log, but it doesn’t appear that is the case anymore. The only thing I can find is the actual variable names used logged.

I’ve confirmed the MCEBPostProcess.bat and the TVTransfer.bat are working when manually constructing CMD session using the file name produced by MCE.

---

<div class="post-metadata">

### Author: ![RBoy](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@RBoy](https://discussion.mcebuddy2x.com/u/RBoy)
#### Post date: [August 2, 2017, 2:09pm UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/6 "2017-08-02T14:09:16Z")

</div>

Just modify your batch file to print the input variables and enclose them in quotes so you can see any white spaces or write them to a text file.

---

<div class="post-metadata">

### Author: ![Robert](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://discussion.mcebuddy2x.com/u/Robert)
#### Post date: [August 2, 2017, 8:01pm UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/7 "2017-08-02T20:01:20Z")

</div>

It doesn’t appear anything is being passed.

The text file is empty (I’m writing out the variables to a text file), but If I run the .bat file manually using:

> “e:\videocaptures\cleaned files\mcebpostprocess.bat” “E:\VideoCaptures\Cleaned Files\Cops Dirty Laundry s30 e07 07-29-2017.ts” E:\VideoCaptures\Cops-S30E07-DirtyLaundry-62792569-0.ts “E:\VideoCaptures\Cleaned Files” 1080 .ts 2.500.852 07 28 2017 05

I get this:

> BatFileName “E:\VideoCaptures\Cleaned Files\TVTransfer.bat”  
> VideoOutPut “Cops Dirty Laundry s30 e07 07-29-2017”  
> VideoInPut “Cops-S30E07-DirtyLaundry-62792569-0”  
> FolderOutPut “E:\VideoCaptures\Cleaned Files”  
> VideoWidth “1080”  
> OutputExt “.ts”  
> FileSize “2.500.852”  
> Month “07”  
> Year “2017”  
> Season 05

Here is the modified mcebpostprocess.bat

> ECHO ON
> 
> setlocal EnableDelayedExpansion
> 
> SET BatFile=“E:\VideoCaptures\Cleaned Files\TVTransfer.bat”  
> SET OutputFileName=“%~n1”  
> SET InputFileName=“%~n2”  
> SET FolderOutput=“%~3”  
> SET WideoWidth=“%~4”  
> SET OutputExtension=“%~5”  
> SET OutputFileSize=“%~6”  
> SET OADMonth=“%~7”  
> SET OADDay=“%~8”  
> SET OADYear=“%~9”  
> SHIFT /4  
> SET SEASON=%~9
> 
> echo BatFileName %BatFile% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt  
> echo VideoOutPut %OutputFileName% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt  
> echo VideoInPut %InputFileName% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt  
> echo FolderOutPut %FolderOutput% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt  
> echo VideoWidth %WideoWidth% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt  
> echo OutputExt %OutputExtension% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt  
> echo FileSize %OutputFileSize% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt  
> echo Month %OADMonth% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt  
> echo Year %OADYear% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt  
> echo Season %SEASON% \>\> C:\Users\Wolverine\Desktop\MCEVARS.txt
> 
> Call %BatFile% %OutputFileName% %InputFileName% %FolderOutput% %WideoWidth% %OutputExtension% %OutputFileSize% %OADMonth% %OADDay% %OADYear% %SEASON%

---

<div class="post-metadata">

### Author: ![RBoy](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@RBoy](https://discussion.mcebuddy2x.com/u/RBoy)
#### Post date: [August 2, 2017, 9:28pm UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/8 "2017-08-02T21:28:26Z")

</div>

Then your file has no metadata. Go through your conversion log to see what metadata Is being extracted from your file or attach your conversion log

---

<div class="post-metadata">

### Author: ![Robert](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://discussion.mcebuddy2x.com/u/Robert)
#### Post date: [August 2, 2017, 11:09pm UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/9 "2017-08-02T23:09:29Z")

</div>

I don’t know what to look for so I’ve attached it.

[Cops-S30E07-DirtyLaundry-62792569-0.ts-TS-2017-08-02T16-01-23.2099867-04-00.zip](https://mcebuddy-discussion-forum.s3.amazonaws.com/original/1X/320d0447fc68b60ea26239eab69af09980f80097.zip) (36.3 KB)

---

<div class="post-metadata">

### Author: ![Robert](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://discussion.mcebuddy2x.com/u/Robert)
#### Post date: [August 2, 2017, 11:12pm UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/10 "2017-08-02T23:12:48Z")

</div>

I don’t understand how MCE can rename the file with most of the same information that is being requested in the variables and still fail. I will assume the information is derived from 2 different places?

I don’t know, but this has my head spinning.

---

<div class="post-metadata">

### Author: ![p37307](https://discussion.mcebuddy2x.com/user_avatar/discussion.mcebuddy2x.com/p37307/32/73_2.png) [@p37307](https://discussion.mcebuddy2x.com/u/p37307)
#### Post date: [August 2, 2017, 11:46pm UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/12 "2017-08-02T23:46:02Z")

</div>

I assume the the bat file really is set to `SET sPAT="\\SERVER\Recorded TV\Other Shows"` for the server and the forum software made it _SET sPAT="\SERVER\Recorded TV\Other Shows"_ in the above comment.

---

<div class="post-metadata">

### Author: ![Robert](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://discussion.mcebuddy2x.com/u/Robert)
#### Post date: [August 3, 2017, 12:03am UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/13 "2017-08-03T00:03:45Z")

</div>

Yes, that is correct.

---

<div class="post-metadata">

### Author: ![RBoy](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@RBoy](https://discussion.mcebuddy2x.com/u/RBoy)
#### Post date: [August 3, 2017, 4:16am UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/14 "2017-08-03T04:16:10Z")

</div>

> [@Robert](#):
>
> PostCustomCommandPath=“E:\VideoCaptures\Cleaned Files\MCEBPostProcess.bat"

I missed this completely, this is your issue. You’ve encapsulated your executable in quotes, when passed to Windows it throws an illegal path error because the path/filenames should not contain a `"` character. Remove that it should work fine, it should look like:

`PostCustomCommandPath=E:\VideoCaptures\Cleaned Files\MCEBPostProcess.bat`

Side note, you way want to update to today’s 2.4.8 BETA build, I noticed an issue with your IMDB metadata matching which we’ve patched up and that should give you your missing parental rating also.

EDIT: In today’s build we’ve also put a check for this invalid `"` character and MCEBuddy will remove it from the CustomCommandPath if encountered to avoid this failure.

---

<div class="post-metadata">

### Author: ![Robert](https://discussion.mcebuddy2x.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://discussion.mcebuddy2x.com/u/Robert)
#### Post date: [August 3, 2017, 10:46am UTC](https://discussion.mcebuddy2x.com/t/custom-command-failing/329/15 "2017-08-03T10:46:56Z")

</div>

That was it, removed the quotes and presto worked like a charm!

Thanks for correcting the parental rating issue so fast!
