Arthor
Arthor

Reputation: 674

Batch Script - Export text file with infomraiton inside

We are using RMTP for our video server, however we must create a SMIL (Synchronized Multimedia Integration Language) file per a video. If you have 1 video, no problem, however we have over 2000 +.

Below you can see a perfect SMIL file. This one is saved as video-test.smil

<smil>
<head>
<meta base="rtmp://xxx.cloudfront.net:1935/cfx/st/" />
</head>
<body>
<switch>
<video src="video-streaming/video-test-720.mp4" height="720" system-bitrate="2000000" width="1280" />
<video src="video-streaming/video-test-360.mp4" height="360" system-bitrate="800000" width="640" />
<video src="video-streaming/video-test-180.mp4" height="180" system-bitrate="300000" width="320"/>
</switch>
</body>
</smil>

My idea would be to make a batch script to do the following:

  1. Read folder and create array with ONLY file names that have .MP4 extensions
  2. Take first array and REPLACE "video-test" with name from first array
  3. Export file with the same name from first part of array with .smil in a folder
  4. Incremment array and repeat

Special feature would be to SKIP if file exsits.

Questions:

Can this even be done with a SCRIPT. Can someone help..

Thanks

Upvotes: 0

Views: 435

Answers (1)

Magoo
Magoo

Reputation: 80113

@ECHO OFF
SETLOCAL
SET targetdir=.
FOR /f %%i IN ('dir /b/a-d *.mp4') DO (
IF NOT EXIST %targetdir%\%%~ni.smil (
FOR /f "tokens=1*delims=#" %%s IN (smiltemplate.txt) DO (
SET subs=%%t
IF DEFINED subs (ECHO %%s%%~ni%%t) ELSE (ECHO %%s)
)
) >%targetdir%\%%~ni.smil
)

save your perfect smil file as smiltemplate.txt - with the string video-test replaced by #

change the target directory to where you want to generate the .smils and all's done!

Upvotes: 2

Related Questions