VideoHelp Forum
+ Reply to Thread
Results 1 to 10 of 10
Thread
  1. Member
    Join Date: Feb 2014
    Location: United Kingdom
    Search Comp PM
    I've written a batch file that successfully creates AVS files (based on the input files that were drag-dropped onto the batch) and encodes them using FFMPEG; however, I would like to be able to check if the user has installed AviSynth, and do so from within the batch file.

    1) What is the best way to do this?

    On my computer I could do something like IF EXIST "C:\Program Files (x86)\AviSynth 2.5" but that is far from foolproof and will only work for version 2.5, and the folder (and even files within) might exist even if AviSynth has been installed.


    2) While I'm asking, if I want to include a whole (large) AVS file in a batch file, so that the batch file will write it into an AVS, I know I need to escape the content (especially the brackets) and use the likes of ECHO or TYPE to put the text line by line into a .avs file, but is there an easy way to automatically escape all the lines? Ideally a wee program (or batch file, indeed) that would also add the ECHO or TYPE commands for each line. I don't even know which characters need to be escaped.

    Thanks!
    Quote Quote  
  2. You can search for avisynth.dll in %SYSTEMROOT%\System32\ or %SYSTEMROOT%\SysWOW64\. It's still possible the dll is there but AviSynth isn't registered.
    Quote Quote  
  3. 2)
    some signs like "&" if you have functions in script, then must be "^&", but there should be no problem using ECHO , common characters like = ( ) are ok after ECHO,
    this is not a problem really because when something needs to be escaped you just read that script that batch created and you can see exactly at what point, character, it went wrong
    Quote Quote  
  4. Member
    Join Date: Feb 2014
    Location: United Kingdom
    Search Comp PM
    Thanks guys.

    I had searched for avisynth.dll in %SYSTEMROOT%\System32\ but couldn't find it. Turns out it's in %SYSTEMROOT%\SysWOW64\ on my PC, so that's just fine Hopefully those are the only two locations avisynth.dll could exist.

    Regarding escaping the AVS, I found this frikkin' awesome way of including a web page (actually an HTML application) within a batch file without escaping it. I should be able to easily modify it to use an AVS file:

    http://www.ericphelps.com/batch/samples/hta_password.bat.txt

    (My AVS is 18kB at the moment and getting bigger by the day, so it's useful to not have to escape it problem by problem!)

    The method above uses the line:

    type %0 | find " " | find /v "Not Me!" > %TEMP%\UserIn.hta

    It copies all the lines of the current batch file that have " " (four consecutive spaces) anywhere in the line, but not the phrase "Not Me!". This means each line of code can have four spaces put at the start and it will be picked up! Genius solution.
    Last edited by as264; 9th Feb 2014 at 18:38. Reason: URL messed up
    Quote Quote  
  5. Originally Posted by as264 View Post
    I had searched for avisynth.dll in %SYSTEMROOT%\System32\ but couldn't find it. Turns out it's in %SYSTEMROOT%\SysWOW64\ on my PC, so that's just fine Hopefully those are the only two locations avisynth.dll could exist.
    Under 32 bit Windows avisynth.dll will be in system32. Under 64 bit windows 32 bit avisynth.dll will be in syswow64, 64 bit avisynth.dll will be system32 (no, those are not typos). Be aware that 32 bit programs cannot access 64 bit AviSynth, and vice versa.
    Quote Quote  
  6. nice to share this
    Code:
    type %0 | find "    " | find /v "Not Me!" > %TEMP%\UserIn.hta
    those four spaces come out alright wrapped in code tag, "Go advanced" button before posting.
    Quote Quote  
  7. I would just redirect TYPE (of another file) to the output file:

    Code:
    TYPE prototype.avs >new.avs
    If I need to append anything I just use >>. Here's a batch file that builds a simple AVS script:

    Code:
    echo import("C:\Program Files (x86)\AviSynth 2.5\plugins\Null.avs") > "%~d1%~p1%~n1.avs"
    echo Mpeg2Source("%~d1%~p1%~n1%~x1", CPU=2, Info=3) >> "%~d1%~p1%~n1.avs"
    echo TFM(d2v="%~d1%~p1%~n1%~x1") >> "%~d1%~p1%~n1.avs"
    echo TDecimate() >> "%~d1%~p1%~n1.avs"
    That lives in my SendTo folder as AVS-Mpeg2Source.bat. So I can right click on a d2v file and select SendTo -> AVS-Mpeg2Source.bat. Right clicking on a file called filename.d2v results in a file called filename.avs in the same folder. The avs file contains:

    Code:
    import("C:\Program Files (x86)\AviSynth 2.5\plugins\Null.avs") 
    Mpeg2Source("full\path\to\filename.d2v", CPU=2, Info=3) 
    TFM(d2v="full\path\to\filename.d2v") 
    TDecimate()
    Last edited by jagabo; 9th Feb 2014 at 23:42.
    Quote Quote  
  8. Member
    Join Date: Feb 2014
    Location: United Kingdom
    Search Comp PM
    @jagabo : yes, I'm using TYPE and appending with >> at the moment. It's just for giving someone else the .bat to use; it would be convenient for everything (including the .avs) to be within one file. They're totally non-tech-savvy so in reality I'm going to probably have to give them AviSynth, ffmpeg.exe, a couple of AviSynth plugins, some images that get used by the avs, the big AVS and the batch file, all in one file.

    I'm going to give "bat2exe.exe" a go to put everything in one .exe that automatically passes on any arguments to the .bat file within. Hopefully the .bat and .avs will be able to access all the files within; or at least be able to copy the files into a temporary directory each time and delete them after. If that doesn't work I guess I'll have to use a .zip file with everything in one folder at least, or is there a better solution? I want to have just one file onto which they can just drag-drop as many video files as they like and it will process and encode them all.


    ps - I think "%~d1%~p1%~n1%~x1" can be abbreviated to "%~dpnx1" - unless there is some advantage to separating all the parts?

    pps - now I see the Go Advanced option.
    Quote Quote  
  9. Originally Posted by as264 View Post
    ps - I think "%~d1%~p1%~n1%~x1" can be abbreviated to "%~dpnx1"
    Thanks, I didn't know that.
    Quote Quote  
  10. Originally Posted by as264 View Post
    "%~d1%~p1%~n1%~x1" can be abbreviated to "%~dpnx1" - unless there is some advantage to separating all the parts?
    it is the same, bottom line is avoiding %1, because Windows puts quotes around file name if there is a space character in the path, which can bring double quotes around file and things do not work,

    you can use even %whatever_file% into avisynth and branch script if avs is inside the same BAT, that is the advantage,
    another advantage to have delivered in zip, folder structure, that you can have included some tool folder , with another programs in it or folders, plugins etc..., then you can use "%~dp0" that returns path of BAT file, wherever it is in PC, you can get something like this:
    Code:
    :: user can set temp folder anywhere like: set path_temp=E:\temp and it will create temp on E:\
    :: today folks use SSD and such, you do not want much activity on SSD, so any temp files 
    :: in script should go to the temp folder
    :: temp folder could be simply deleted at the end
    
    set path_temp=%~dp0temp
    MD "%path_temp%"
    SET input_name=%~d1%~p1%~n1%~x1
    SET name=%~n1
    SET temp_adr=%path_temp%\%name%
    SET plugin_folder=%~dp0tools\plugins
    SET DGDecode.dll=%~dp0tools\dgindex\DGDecode.dll
    .
    .
    .
    
    echo Load_Stdcall_Plugin("%plugin_folder%\yadif.dll")              >> "%temp_adr%.avs"
    echo LoadPlugin("%DGDecode.dll%")                                         >> "%temp_adr%.avs"
    echo MPEG2Source("%temp_adr%.d2v")                                    >> "%temp_adr%.avs" 
    
    if "%field_order%" EQU "none" goto :end_avs_script 
    
    echo Assume%field_order%()                                                >> "%temp_adr%.avs"
    echo Yadif(mode=1,order=1)                                                 >> "%temp_adr%.avs"
    
    :end_avs_script
    EDIT:I corrected script, sorry, did not notice the wrong paths
    Last edited by _Al_; 10th Feb 2014 at 14:49.
    Quote Quote  



Similar Threads