Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: I want to add a single line from a list to a template and then save as bat file  (Read 3766 times)

0 Members and 1 Guest are viewing this topic.

Jerry_s

    Topic Starter


    Greenhorn

    • Experience: Beginner
    • OS: Unknown
    In a For loop you have the x++ that adds 1 to x every loop.

    Text file "Template A" , line 5, uses line one from text file "B", then saves the file as 1.txt.

    Then Text file "Template A" , line 5, uses line two from text file "B", then saves the file as 2.txt.

    It does this for all 500 lines in text file "B", so after it's done there is 500 text files.

    Here is my template:

    Code: [Select]
    loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")

    directshowsource("C:\Users\Jeremy\Desktop\D H.avi", audio=false, 23.976)

    trim(0, 93)

    converttoyv12()

    Here is the trim list I want to use in the template:

    Code: [Select]
    trim(94,153)
     trim(154,197)
     trim(198,249)
     trim(250,287)
     trim(288,331)
     trim(332,398)
     trim(399,420)
     trim(421,467)
     trim(468,485)
     trim(486,512)
     trim(513,526)
     trim(527,540)
     trim(541,592)
     trim(593,633)
     trim(634,653)
     trim(654,688)
     trim(689,714)
     trim(715,787)
     trim(788,848)
     trim(849,880)
     trim(881,925)
     trim(926,942)
     trim(943,966)
     trim(967,975)
     trim(976,995)
     trim(996,1012)
     trim(1013,1027)
     trim(1028,1036)
     trim(1037,1055)
     trim(1056,1075)
     trim(1076,1150)

    So the final template has this new trim value:

    Code: [Select]
    [code]
    loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")

    directshowsource("C:\Users\Jeremy\Desktop\D H.avi", audio=false, 23.976)

    trim(94,153)

    converttoyv12()
    [/code]

    Jerry_s

      Topic Starter


      Greenhorn

      • Experience: Beginner
      • OS: Unknown
      I found this bat file:

      Code: [Select]
      @echo off
      setlocal enabledelayedexpansion

      Rem ===================================================================
      Rem Batch for inserting a line into every AVS file in a specific
      Rem directory
      Rem
      Rem Usage: insline [directory] [text] [line number]
      Rem
      Rem Make sure to use quotes around directory and text.
      Rem
      Rem Example: insline "d:\rebuild\d2vavs" "undot().deen()" 2
      Rem
      Rem          Recursively scans directory d:\rebuild\d2vavs for .AVS
      Rem          files and inserts undot().deen() at line number 2 into
      Rem          every .AVS. -1 for line number appends at end of file.
      Rem ===================================================================
      if "%~1" == "" goto :EOF
      if "%~2" == "" goto :EOF
      if "%~3" == "" goto :EOF
      if not exist "%~1" goto :EOF

      set text=%~2
      for /R "%~1" %%F in (*.avs) do (
        set line=0
        if "%~3" == "-1" (
          echo !text!>>"%%F"
        ) else (
          if exist "%%~dpnF.$$$" del "%%~dpnF.$$$"
          for /F "usebackq delims=" %%I in ("%%F") do for /F "tokens=1 delims= " %%J in ("%%I") do (
            set char=%%J
            set char=!char:~0,1!
            if not "!char!" == "#" (
              set /A "line += 1"
              if "!line!" == "%~3" echo !text!>>"%%~dpnF.$$$"
            )
            echo %%I>>"%%~dpnF.$$$"
          )
          del "%%F"
          ren "%%~dpnF.$$$" "%%~nxF"
        )
      )

      But I don't know how to use it. Could somebody here post to show how?

      Salmon Trout

      • Guest
      Here is the trim list I want to use in the template:

      Code: [Select]
      trim(94,153)
       trim(154,197)
       trim(198,249)
       trim(250,287)
       trim(288,331)
       trim(332,398)
       trim(399,420)
       trim(421,467)
       trim(468,485)
       trim(486,512)
       trim(513,526)
       trim(527,540)
       trim(541,592)
       trim(593,633)
       trim(634,653)
       trim(654,688)
       trim(689,714)
       trim(715,787)
       trim(788,848)
       trim(849,880)
       trim(881,925)
       trim(926,942)
       trim(943,966)
       trim(967,975)
       trim(976,995)
       trim(996,1012)
       trim(1013,1027)
       trim(1028,1036)
       trim(1037,1055)
       trim(1056,1075)
       trim(1076,1150)

      So the final template has this new trim value:

      Code: [Select]
      [code]
      loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")

      directshowsource("C:\Users\Jeremy\Desktop\D H.avi", audio=false, 23.976)

      trim(94,153)

      converttoyv12()

      1. There are only 31 trim lines. Where does the 500 figure come from? (You want to process a text file with 500 lines? What is it called? What does it contain?)

      2. The "final" template has the trim value "(94,153)" yet this is the ***first*** value of the trim list. Huh?

      I have done a bit of Avisynth/VirtualDub scripting so I understand a bit of this kind of thing, it might be helpful if you describe the task you are trying to accomplish.




      Jerry_s

        Topic Starter


        Greenhorn

        • Experience: Beginner
        • OS: Unknown
        I need the bat file to do a trim of a source file. The trim will take a clip from a source file.
        I want to make the bat file and then double clip it and it will trim the clip from the source file.

        The first trim is from frame 0 to 93, this is the first scene, then the second clip is from frame 94 to 152, this is the second scene in the movie.
        Every trim is the beginning frame and end frame of a scene in the video.

        I was told that you can't do all the trims at once in a single script, you need to do the trims individually in their own encode.

        That 500 number is a imaginary number, the trim list is of a actual video clip from a trailer.

        Salmon Trout

        • Guest
        Quote from: Me, before
        The "final" template has the trim value "(94,153)" yet this is the ***first*** value of the trim list. Huh?

        Jerry_s

          Topic Starter


          Greenhorn

          • Experience: Beginner
          • OS: Unknown
          What I mean by Final is the making of a new file.
          The first file is trim(0, 93)

          By doing the work I will make "a new file" with the trim(94, 152), then save this new file. Then I want to run this bat file and get the clip in the folder the bat file says it should be in.
          Then when I can do this this is the final result. I should have said final Result, and not just Final.

          Salmon Trout

          • Guest
          You aren't explaining what you want to do clearly enough.

          Jerry_s

            Topic Starter


            Greenhorn

            • Experience: Beginner
            • OS: Unknown
            Ok, I will clearly define what I want to do.

            Step 1.) I have a avs file that is a template; it has a line called Trim().
            This template can be encoded using either a bat file or a avs encoder like megui.

            When the file is encoded it will save a video clip of the source file. This clip is only one scene though.

            In the trailer the frames go from from 0 to 1150, there are 25 scenes in there; 25 scenes makes 25 trim() in a list.
            I have this list of 25 trim, but I only have the template avs file and when that's used in encoding I only have one video clip.

            Step 2.) I want to create 25 different clips; all 25 scenes from the trailer.

            Step 3.) How do I use this avs template file, and this list of trim() and get all 25 scenes from the trailer? I need to change the trim() in the template file with a single new trim from the list of trim and then encode the template file and get the second clip from the trailer that shows the next scene.

            Step 4.) Now I have two clips, I need to get all 25 clips, somehow.

            Salmon Trout

            • Guest
            Thanks. I will be having a look at this today and hope to post back later.