Author Topic: help with batch file?  (Read 7760 times)

Offline musictrivianut

  • Contributor
  • ***
  • Posts: 34
help with batch file?
« on: July 11, 2010, 02:15:04 am »
Well, I ran a few searches (mkv, m2ts and convert) and didn't find anything, so here's hoping that someone out there might be able to help me out or point me in the right direction.

First, I will note that I am not having any problems with altbinz.  It's a fantastic program.  I just want to know if I can make it do what I want it to do.

Without going into specifics, what I would like is for the batch file executed after a download is finished to convert a file from mkv to m2ts.  I already use the batch file to clean up the download directory (thanks to those that posted about how to do that).  However, after downloading some mkv files and then discovering that they do not play natively when served to my PS3, but m2ts files are, I have been converting them one at a time using tsMuxeR.  I figure, altbinz is already downloading the file, why not see if it can do the conversion also.  Unfortunately, I know extremely little about batch programming and even less about how tsMuxeR does what it does.

Has anybody else out there figured out how to do this and can show me?  Thanks.

Offline davidq666

  • Contributor
  • ***
  • Posts: 1302
  • Watashi Wa Ero Desu!
Re: help with batch file?
« Reply #1 on: July 11, 2010, 12:13:56 pm »
a direct file conversion via batchfile will not be possible, the only outside chance u might have is using a batchfile to transfer the corect file automaticaly to a third party for processing.

Offline musictrivianut

  • Contributor
  • ***
  • Posts: 34
Re: help with batch file?
« Reply #2 on: July 11, 2010, 03:05:47 pm »
Transfer the file to a third party?  You mean somehow get altbinz to pass the name of the file that it just unrared to another program that will write the meta file and then run tsMuxeR?

I wish I new more programming.

<sigh>  If I'm stuck doing things the hard way, that's fine and it's certainly not the fault of altbinz or the creator.  I'll live  ;D

Thanks.

Offline davidq666

  • Contributor
  • ***
  • Posts: 1302
  • Watashi Wa Ero Desu!
Re: help with batch file?
« Reply #3 on: July 12, 2010, 08:40:05 am »
not excatly. i was thinking it might be possible to use a batch script to pass the name (via $col if collection name=filename) and auto start tsmuxer or a simular software to do the conversion...

Offline musictrivianut

  • Contributor
  • ***
  • Posts: 34
Re: help with batch file?
« Reply #4 on: July 12, 2010, 12:16:35 pm »
Yeah, that's the kind of thing I was looking for; a line or so in the batch file to tell tsMuxeR what it needs to know to mux the file to m2ts format.

Offline Hecks

  • Contributor
  • ***
  • Posts: 2011
  • naughty cop
Re: help with batch file?
« Reply #5 on: July 12, 2010, 03:54:10 pm »
The translation of the tsMuxeR readme file that explains commandline usage is here:

http://forum.doom9.org/archive/index.php/t-134104.html

This is somewhat outside the scope of this forum, maybe you'll have better luck getting some answers with:

http://www.google.com/search?q=tsMuxeR+commandline

Offline musictrivianut

  • Contributor
  • ***
  • Posts: 34
Re: help with batch file?
« Reply #6 on: July 12, 2010, 04:01:11 pm »
Thank you very much.  I will start there (the Russian readme wasn't doing me much good).  Greatly appreciated.

Offline musictrivianut

  • Contributor
  • ***
  • Posts: 34
Re: help with batch file?
« Reply #7 on: July 12, 2010, 08:19:25 pm »
Am still hoping that someone can help me figure out how to do this with a batch file, if possible.  After reading the link given to the Execute Command and some other sites on scripting, I think I have a basic outline for what needs to happen, but for some reason, it looks like altbinz may not be passing variables correctly (or I'm not writing it correctly).

Following the instructions for Execute Command, my Default execute command (NZB #2) is "C:\Program Files (x86)\AltBinz\cleanup.bat" "$d $col".

The cleanup.bat file currently contains:

@echo off
del c:\temp\*.nfo
del c:\temp\*.srr
del c:\temp\*.srs

rem trying to convert downloaded files from mkv to m2ts using tsmuxer.exe

rem set variables

set dldir=%1
set colname=%2
set metafile=%dldir%\%colname%.meta


rem echo text >> %metafile% should write text to meta file

echo MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr  --vbv-len=500 >> %metafile%
echo V_MPEG4/ISO/AVC, "%dldir%\%colname%", fps=23.976, insertSEI, contSPS, track=1, lang=eng >> %metafile%
echo A_AC3, "%dldir%\%colname%", track=2, lang=und >> %metafile%


However, the .meta file ends up in the root directory, not in the download directory and the text written to the file is "\" with no directory or file information.  Does that mean that the variables are empty?

Any ideas on what is going on?  What am I doing wrong?  Is there any additional information that I can give to help?

I figure, once I can get it to write the meta file correctly, it should be easy to call txmuxer with the correct parameters, have it do the conversion and then delete the original file.

Thanks.

Offline Hecks

  • Contributor
  • ***
  • Posts: 2011
  • naughty cop
Re: help with batch file?
« Reply #8 on: July 12, 2010, 09:06:20 pm »
Do the directory names have spaces in them? In which case try adding extra single quotation marks, e.g. "'$d' $col".  And then double quotation marks e.g. here:

Code: [Select]
set metafile="%dldir%\%colname%.meta"

Deciding where the quotation marks go is a fiddly thing about batch scripting that's best to test outside of Alt.Binz first.  Test with lines like:

Code: [Select]
if exist %metafile% echo Yes it exists!
« Last Edit: July 12, 2010, 09:16:24 pm by Hecks »

Offline musictrivianut

  • Contributor
  • ***
  • Posts: 34
Re: help with batch file?
« Reply #9 on: July 13, 2010, 01:00:41 am »
Well, there are no spaces in the directory; everything goes right into c:\temp.  I have tried all kinds of combinations for the Default Execute Command:

"C:\Program Files (x86)\AltBinz\cleanup.bat" $d $col
"C:\Program Files (x86)\AltBinz\cleanup.bat" "$d $col"
"C:\Program Files (x86)\AltBinz\cleanup.bat" "'$d' '$col'"
"C:\Program Files (x86)\AltBinz\cleanup.bat" "$d" "$col"

and they all produce the same result from the following code:

:set_logfile
set logfile=C:\temp\dldlog.txt
if not exist %logfile% echo Alt.binz Download Log >> %logfile%

:set_variables
set dldir=%1
set colname=%2

echo download directory is %dldir% >> %logfile%
echo collection name is %colname% >> %logfile%


Alt.binz Download Log
download directory is
collection name is


Just blanks, both of them.  Again, if I can figure out what I'm doing wrong with passing the variables, I might be able to do what I want with the batch file and automating the conversion.

Thanks for all the help so far.  I'll get it someday.

Offline Hecks

  • Contributor
  • ***
  • Posts: 2011
  • naughty cop
Re: help with batch file?
« Reply #10 on: July 13, 2010, 02:08:06 am »
Hmm, odd.  The only thing I can propose next is to try $d and $col on their own to see which might be causing a prob.  Certainly the logging script you're using there does work. 

Or maybe the Kraken can be summoned to explain exactly how these parameters are passed to cmd.exe by Alt.Binz ...

*Hecks starts the drumming*

Offline musictrivianut

  • Contributor
  • ***
  • Posts: 34
Re: help with batch file?
« Reply #11 on: July 13, 2010, 03:33:20 am »
I tried all the same things with the quotes using just $col with the same results, an empty variable.  I really appreciate all the effort that you guys are putting into this for me.  Maybe once we figure it out, I'll have something I can submit to the Code thread for everybody else that might be interested in the same thing.

Offline musictrivianut

  • Contributor
  • ***
  • Posts: 34
Re: help with batch file?
« Reply #12 on: July 14, 2010, 03:09:25 am »
Okay, I still have no clue why the program isn't passing variables the way that it's supposed to.  I know that the Wiki (https://www.altbinz.net/wiki/Execute_Command_on_Completion) shows that the format is supposed to be

   c:\util\MyCleanupRoutine.exe "-a $d"
   c:\util\CleanupAfterUnrar.bat "$d $u"

with quotes around the parameters, but not the command.  But there is another thread (https://www.altbinz.net/forum/index.php?topic=3354.msg14064#msg14064) where someone else seemed to have difficulty with variables also and he posted that

   "C:\My Stuff\Alt.BinZ 0.31.2 binary news reader\logdownloads.bat" $d $u

worked for him.  Quotes around the batch file command, but not the parameters being passed, opposite of what is shown in the Wiki.  As I mentioned, I've tried all different variations with zero results.  However, I noted that the other user was on WinXP.  I am using Win7, 64-bit Edition.  That wouldn't have anything to do with it, would it?  I mean, is there any difference in the way the two different OSes handle executing commands?

I'm just throwing things out there.  Further thoughts?

Offline Hecks

  • Contributor
  • ***
  • Posts: 2011
  • naughty cop
Re: help with batch file?
« Reply #13 on: July 14, 2010, 09:31:49 am »
Quote
I already use the batch file to clean up the download directory (thanks to those that posted about how to do that).

But it's working in this case?

Offline musictrivianut

  • Contributor
  • ***
  • Posts: 34
Re: help with batch file?
« Reply #14 on: July 14, 2010, 12:56:22 pm »
Yes, it does everything else just fine, the only thing it doesn't like is the variable.

And I am using the most current version, 0.31.6, in case I hadn't mentioned it yet.

When the batch file runs, the command window just flashes by.  Is there a way to prevent it from disappearing, so I can see if there is an error or something?  I checked the properties for the file, but didn't see anything.