quake 3 commands | Cell 9 | Cell 11 | Search

This script converts all .wav files in the current directory and its subdirectories to .opus format, using either a Windows command-line script or a Bash translation. The script can also be modified to simply echo the file paths instead of performing the conversion.

Cell 10


for /r %%v in (*.wav) do opusenc "%%v" "%%~dpv%%~nv.opus"

#TODO: WOOOO! Bash pattern, convert this with transpiler to match linux loops with same filename extension operation
#bash
for i in $(find . -iname '*.wav'); do opusenc "$i" "${i%.wav}".opus; done

for i in $(find . -iname '*.wav'); do echo "$i"; done

What the code could have been:

#!/bin/bash

# Find all.wav files recursively in the current directory
for file in $(find. -iname '*.wav'); do
  # Convert.wav files to.opus
  opusenc "$file" "${file%.wav}.opus"
  echo "Converted: $file"
done

Code Breakdown

Windows Command-Line Script

for /r %%v in (*.wav) do opusenc "%%v" "%%~dpv%%~nv.opus"

This is a Windows command-line script that loops through all .wav files in the current directory and its subdirectories.

Bash Translation

for i in $(find. -iname '*.wav'); do opusenc "$i" "${i%.wav}".opus; done

This is the equivalent Bash script for the above Windows command-line script.

Echo Command

for i in $(find. -iname '*.wav'); do echo "$i"; done

This script does the same as the previous one but instead of converting the files, it simply echoes the file paths.