I’ve already mentioned the Fabric framework, which attempts to minimize the friction between AI and users in several blog posts. I still plan on doing posts showing step-by-step how to install Fabric on different operating systems, but in the meantime, I wanted to show an example of shortcuts I use on Windows to make Fabric even more user-friendly.
On my daily driver system, I have fabric installed in a folder, and that folder was added to my system’s path so I can run fabric from anywhere. Normally, if I wanted to use the “summarize” pattern to summarize the content of a YouTube video, this would be my syntax:
fabric -p summarize --transcript -y “URL_OF_VIDEO”
That is not a long or complicated command, but we can make it even shorter and more effortless with batch files. A Windows batch file (.bat extension) can be created, viewed, and edited with a text editor and run as an executable. In the same folder I have Fabric installed, I have a file named “ytsum,bat” with the following content:
@echo off
setlocal
if "%~1"=="" (
echo Usage: ytsum "YouTube_URL"
echo Please enclose the URL in double quotes.
goto :eof
)
set "URL=%~1"
echo Processing "%URL%"
rem Escape special characters in the URL
call :EscapeSpecialChars "%URL%"
fabric -p summarize --transcript -y "%URLEscaped%"
endlocal
goto :eof
:EscapeSpecialChars
set "URLEscaped=%~1"
set "URLEscaped=%URLEscaped:^=^^%"
set "URLEscaped=%URLEscaped:&=^&%"
exit /b
With this file contained in the folder in the system’s path, I can open a command prompt window from any location and type “ytsum “video_url” and, within seconds, get a well-formatted summary of the video in markdown. Here is a breakdown of what the script does:
Check if a YouTube URL was provided
– If no parameter (`%~1`) is passed to the script, it prints a usage message telling you how to use the script and then stops (`goto :eof`).
Store the URL in a variable
– It takes the first parameter (the YouTube URL) and saves it in a variable called `URL`.
Tell the user what is being processed
– It displays a message: `Processing “the URL you provided”`.
Escape special characters in the URL
– The batch file calls a subroutine named `:EscapeSpecialChars`.
– This subroutine takes the URL and replaces certain special characters (like `^` and `&`) with their “escaped” versions (`^^` and `^&`). This is done so that these characters don’t cause problems when passed to the next command.
Run the `fabric` command with the escaped URL
– After escaping, the script runs a command:
fabric -p summarize --transcript -y "%URLEscaped%"
which presumably summarizes the transcript of the provided YouTube URL.
Clean up and exit
– The script ends the local environment variables (`endlocal`) and then exits.
Creating batch files with shortcuts like this makes an easy process even easier. Tomorrow, we’ll look at the results from this command with a quick YouTube video review.