Drag and Drop Folders to Create Array & Execute Commands
Posted: 13 Apr 2009 15:43
I hope I can explain this well. The more I think about it, the more confused I get.
I've written a simple batch file that lets a user drag and drop a folder onto it, it gleans a few key filenames from the folder's contents, and then plants those filenames as arguments for a proprietary CLI executable that merges closed-captioning data with a WMV file, based on Windows Media File Editor. This works well for a processing a single folder now and then, but it has come to my attention that we need to re-process hundreds of old folders with updates captions. Rather than drag and drop, wait and hour for it to finish, drag and drop again, wait an hour for it to finish, etc., I'd like to drag and drop a large group of folders at once, therefore I've come here for some expert advice. A few tidbits before I paste in the code: The folders are named by project number, and contain only numbers. Within each folder is a captioning text file, a master source MPEG file, and a multi-bitrate WinMedia file. The output file generated is simply folderName.wmv.
So, if I still have your attention, how can I expand this to let me process multiple folders, one after another?
I've written a simple batch file that lets a user drag and drop a folder onto it, it gleans a few key filenames from the folder's contents, and then plants those filenames as arguments for a proprietary CLI executable that merges closed-captioning data with a WMV file, based on Windows Media File Editor. This works well for a processing a single folder now and then, but it has come to my attention that we need to re-process hundreds of old folders with updates captions. Rather than drag and drop, wait and hour for it to finish, drag and drop again, wait an hour for it to finish, etc., I'd like to drag and drop a large group of folders at once, therefore I've come here for some expert advice. A few tidbits before I paste in the code: The folders are named by project number, and contain only numbers. Within each folder is a captioning text file, a master source MPEG file, and a multi-bitrate WinMedia file. The output file generated is simply folderName.wmv.
So, if I still have your attention, how can I expand this to let me process multiple folders, one after another?
Code: Select all
rem drag a folder onto this file to start script
@echo off
set encoder="C:\Program Files\ScriptEncoder\scriptencoder.exe"
for %%A in (%1\*.txt) do set script_file=%%A
for %%B in (%1\*.mpg) do set source_file=%%B
for %%C in (%1\*mbr.wmv) do set target=%%C
set output_file=%source_file:~0,-4%.wmv
set profile="C:\Program Files\ScriptEncoder\normal.prx"
title %output_file%
rem echo the values to make sure they're correct
echo.
echo.SCRIPT FILE = %script_file%
echo.
echo.SOURCE FILE = %source_file%
echo.
echo. TARGET = %target%
echo.
echo.OUTPUT FILE = %output_file%
echo.
echo. PROFILE = %profile%
echo.
rem start the encoder now
%encoder% ^
%script_file% ^
%source_file% ^
%target% ^
%output_file% ^
%profile%
echo.
echo.
pause
exit