Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I do a bit of encoding and am trying to automate some parts. I have to create an avs script file for the encoding process and would like to be able to make one then have a batch script make more for the rest of the series.
The avs file has a file name in it, which i just use numbers for while i encode. So I'll have to copy the text inside the file, then replace the episode # with the next higher number then write it to a file.
So this is what the first avs file would look like (just making it up don't have one at the moment)
blahblahblah(e:\encoding\series\1.dv2)
interlace(true?)
crop(8,0,-8,0)I would like to read that file, then replace 1.dv2 with 2.dv2 then write it to 2.avs as the file name.
I'm not familiar with reading files or replacing things in batch so if I could get some directions there I'd appreciate it. If it isn't a pain could you just help me with the reading and replacing and let me try to figure out the rest, such as looping and counting.

The secret is to do the file from scratch.
FOR %%a IN (e:\encoding\series\*.dv2) DO @(
ECHO AVISource("%%~Fa"^)
ECHO interlace(true?^)
ECHO crop(8,0,-8,0^)) > %%~Na.avs
NOTE: I know not of an interlace filter. Did you mean bob?

@echo off
setLocal EnableDelayedExpansionfor /f "tokens=* delims= " %%a in (1.avs) do (
set /a N+=1
if !N! equ 1 (
set str=%%a
set head=!str:~0,-6!
set tail=!str:~-6!
set end=!tail:~-5!
set /a #=!tail:~0,1!
set /a #+=1
echo !head!!#!!end!> !#!.avs
) else (
echo %%a>> !#!.avs
)
)
=====================================
If at first you don't succeed, you're about average.M2

Razor2.3
that would indeed the be the easy way to do it, but that requires editing the batch file, also i made up that script stuffM2
Lovely looking script but i think it's off cause of my input.dgdecode_Mpeg2Source("f:\encoding\bebop\1.dv2")
Crop(0,4,-4,0)
Spline36resize(704,528)that is actually what the avs file will look like plus or minus lines. The file name will always be at the end of the first line though.
also i would just like to create the 2-26 avs files since 1 is the template to go off of.

You know, now that I revisit this, I remember the 'S' in AVS stands for Script. This means you can set a template file up like:
dgdecode_Mpeg2Source("f:\encoding\bebop\" + num + ".dv2")
Crop(0,4,-4,0)
Spline36resize(704,528)
Then, your batch file could do:FOR /L %%A IN (1,1,10) DO (
@ECHO num = "%%A" > #
COPY #+template.avs %%A.avs
)

that doesn't seem to be working on my end. I get a # file and %a.avs file when i run it with a template.avs file in the same folder

I took what you did and just made if copy the template an entered number of times.
@echo off
echo enter episodes
set /p ep=
FOR /L %%A IN (1,1,%ep%) DO (
COPY template.avs %%A.avs
)So I'll have a bunch of files with this as the first line
DGDecode_mpeg2source("_placeholder_.d2v",info=3)
I'd like to replace _placeholder_ with the name of the file it's in minus the extension. How can I do that in a new loop after the above script makes them?

well searching around here found me the replacing part i needed. So I whipped this up.
@echo off
setlocal EnableDelayedExpansionecho enter episodes
set /p ep=FOR /L %%A IN (1,1,%ep%) DO (
for /f "tokens=*" %%a in (template.avs) do (
set C=%%a
set B=!C:_replaceme_=%cd%%%A!
echo !B! >> %%A.avs
)
)That takes a template.avs file with _replaceme_ stuck in where the file name goes. Run this and enter how many avs scripts you wish to make and viola they are made.
EDIT
I made it work by myself yay.I did a help for in cmd and got this handy info
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of fileso I made this
@echo off
setlocal EnableDelayedExpansionecho drag and drop avs template into window
set /p avs=
for /f "tokens=* delims= " %%f in ("!avs!") do (
set avs2=%%~dpf
)echo enter episodes
set /p ep=FOR /L %%A IN (1,1,%ep%) DO (
for /f "tokens=*" %%a in (%avs%) do (
set C=%%a
set B=!C:_replaceme_=%avs2%%%A!
echo !B! >> %avs2%%%A.avs
)
)it works as long as the input file has no spaces in it path name

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |