Initial Commit

This commit is contained in:
Nighthawk
2024-07-01 14:26:01 -04:00
parent 4c6e9ee546
commit 37a8fdcd30
6 changed files with 418 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
@echo off
setlocal enabledelayedexpansion
REM Display script information
echo ------------------------------------------------------------------------------
echo Script Name: convert_audio.bat
echo Description: This script converts all audio files in a specified source directory
echo to a chosen format using FFmpeg. The supported formats are MP3, OGG,
echo WAV, FLAC, and AAC.
echo Requirements: FFmpeg must be installed and available in the system's PATH.
echo Author: Nighthawk42
echo ------------------------------------------------------------------------------
REM Prompt the user for the source directory
set /p srcDir=Enter Source Directory:
REM List available formats
echo Select Format.
echo 1. MP3
echo 2. OGG
echo 3. WAV
echo 4. FLAC
echo 5. AAC
REM Prompt the user for the format choice
set /p formatChoice=Enter the number corresponding to the desired format:
REM Determine the chosen format
set format=
if %formatChoice%==1 set format=mp3
if %formatChoice%==2 set format=ogg
if %formatChoice%==3 set format=wav
if %formatChoice%==4 set format=flac
if %formatChoice%==5 set format=aac
REM Validate the chosen format
if "%format%"=="" (
echo Invalid choice. Exiting...
exit /b 1
)
REM Create the output directory
set outDir=%srcDir%\converted
mkdir "%outDir%"
REM Convert files while preserving audio quality
for %%f in ("%srcDir%\*.*") do (
echo Converting "%%f" to "%outDir%\%%~nf.%format%"
if %format%==mp3 (
ffmpeg -i "%%f" -q:a 0 "%outDir%\%%~nf.%format%"
) else if %format%==ogg (
ffmpeg -i "%%f" -q:a 10 "%outDir%\%%~nf.%format%"
) else if %format%==wav (
ffmpeg -i "%%f" "%outDir%\%%~nf.%format%"
) else if %format%==flac (
ffmpeg -i "%%f" -compression_level 12 "%outDir%\%%~nf.%format%"
) else if %format%==aac (
ffmpeg -i "%%f" -b:a 320k "%outDir%\%%~nf.%format%"
)
)
echo Conversion completed.
pause
+128
View File
@@ -0,0 +1,128 @@
@echo off
setlocal EnableDelayedExpansion
echo ------------------------------------------------------------------------------
echo Script Name: discord_compress.bat
echo Description: This script compresses video and audio files to a target size
echo suitable for sharing on Discord. It calculates appropriate bitrates
echo for video and audio files to achieve a target file size of 25MB.
echo Requirements: FFmpeg must be installed and available in the system's PATH.
echo Author: Nighthawk42
echo ------------------------------------------------------------------------------
REM Get the directory and file extension of the input file
set "input_file=%~1"
set "input_directory=%~dp1"
set "input_extension=%~x1"
REM Extract input file name without extension
for %%f in ("%input_file%") do set "input_file_name=%%~nf"
REM Get current time for logging purposes
for /F "tokens=1-3 delims=:." %%a in ("%time%") do (
set "hour=%%a"
set "minute=%%b"
set "second=%%c"
)
set "current_time=%hour%%minute%%second%"
REM Check if input file extension is valid for video
set "video_extensions=.mp4 .avi .mkv .mov .flv .wmv .webm .mpeg .3gp"
echo %video_extensions% | find /i "%input_extension%" >nul && (
call :process_video
goto :eof
)
REM Check if input file extension is valid for audio
set "audio_extensions=.mp3 .wav .m4a .flac .aac .ogg .wma"
echo %audio_extensions% | find /i "%input_extension%" >nul && (
call :process_audio
goto :eof
)
REM If input file extension is not recognized, display error message and exit
echo File type not supported.
echo Terminating compression.
pause
goto :eof
REM Function for processing video files
:process_video
(
echo Processing video file: %input_file%
REM Calculate bitrate based on input file duration
for /f "delims=" %%i in ('ffprobe -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 "%input_file%"') do set "duration=%%i"
set /a "bitrate=23 * 8 * 1000 / duration"
echo Video length: %duration%s
echo Bitrate target: %bitrate%k
REM Exit if target bitrate is under 150kbps
if %bitrate% LSS 150 (
echo Target bitrate is under 150kbps.
echo Unable to compress.
pause
goto :eof
)
REM Allocate bitrate based on video properties
set /a "video_bitrate=bitrate * 90 / 100"
set /a "audio_bitrate=bitrate * 10 / 100"
echo Video Bitrate: %video_bitrate%
echo Audio Bitrate: %audio_bitrate%
REM Exit if target video bitrate is under 125kbps
if %video_bitrate% LSS 125 (
echo Target video bitrate is under 125kbps.
echo Unable to compress.
pause
goto :eof
)
REM Exit if target audio bitrate is under 32kbps
if %audio_bitrate% LSS 32 (
echo Target audio bitrate is under 32.
echo Unable to compress.
pause
goto :eof
)
pushd %input_directory%
echo Compressing video file using FFmpeg...
ffmpeg -hide_banner -loglevel warning -stats -threads 0 -hwaccel auto -i "%input_file%" -preset slow -c:v h264_nvenc -b:v %video_bitrate%k -c:a aac -b:a %audio_bitrate%k -bufsize %bitrate%k -minrate 100 -maxrate %bitrate%k "25MB_%input_file_name%.mp4"
popd
goto :eof
)
REM Function for processing audio files
:process_audio
(
echo Processing audio file: %input_file%
REM Calculate input file duration
for /f "delims=" %%i in ('ffprobe -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 "%input_file%"') do set "duration=%%i"
REM Calculate target bitrate based on input file duration
set /a "bitrate=25 * 8 * 1000 / duration"
echo Audio duration: %duration%s
echo Bitrate target: %bitrate%k
REM Exit if target bitrate is under 32kbps
if %bitrate% LSS 32 (
echo Target bitrate is under 32kbps.
echo Unable to compress.
pause
goto :eof
)
REM Compress audio file using FFmpeg
pushd %input_directory%
echo Compressing audio file using FFmpeg...
ffmpeg -hide_banner -loglevel warning -stats -i "%input_file%" -preset slow -c:a libmp3lame -b:a %bitrate%k -bufsize %bitrate%k -minrate 100 -maxrate %bitrate%k "25MB_%input_file_name%.mp3"
popd
goto :eof
)
+59
View File
@@ -0,0 +1,59 @@
@echo off
setlocal enabledelayedexpansion
echo ------------------------------------------------------------------------------
echo Script Name: extract_audio.bat
echo Description: This script extracts audio from all major video file formats in a
echo specified directory using FFmpeg. The user can select the output
echo audio format.
echo Requirements: FFmpeg must be installed and available in the system's PATH.
echo Author: Nighthawk42
echo ------------------------------------------------------------------------------
REM Prompt the user to enter the directory path
set /p "source_dir=Enter the directory path containing video files: "
REM Check if the directory exists
if not exist "%source_dir%" (
echo Directory not found: "%source_dir%"
exit /b 1
)
REM List available audio formats
echo Select output audio format:
echo 1. AAC
echo 2. MP3
echo 3. WAV
echo 4. FLAC
echo 5. OGG
REM Prompt the user for the format choice
set /p "formatChoice=Enter the number corresponding to the desired format: "
REM Determine the chosen format
set "audio_format="
if %formatChoice%==1 set "audio_format=aac"
if %formatChoice%==2 set "audio_format=mp3"
if %formatChoice%==3 set "audio_format=wav"
if %formatChoice%==4 set "audio_format=flac"
if %formatChoice%==5 set "audio_format=ogg"
REM Validate the chosen format
if "%audio_format%"=="" (
echo Invalid choice. Exiting...
exit /b 1
)
REM Supported video file extensions
set "video_extensions=*.mkv *.mp4 *.avi *.mov *.flv *.wmv *.webm *.mpeg *.3gp"
REM Loop through all video files in the directory
for %%A in (%video_extensions%) do (
if exist "%source_dir%\%%A" (
REM Extract audio using ffmpeg
ffmpeg -i "%source_dir%\%%A" -vn -c:a %audio_format% "%source_dir%\%%~nA.%audio_format%"
)
)
echo Audio extraction complete.
pause
+55
View File
@@ -0,0 +1,55 @@
@echo off
setlocal enabledelayedexpansion
echo ------------------------------------------------------------------------------
echo Script Name: merge_audio.bat
echo Description: This script merges all audio files in the current directory into a
echo single file using FFmpeg. The user can select the output audio format.
echo Requirements: FFmpeg must be installed and available in the system's PATH.
echo Author: Nighthawk42
echo ------------------------------------------------------------------------------
REM Supported audio file extensions
set "audio_extensions=*.wav *.mp3 *.flac *.aac *.ogg"
REM Prompt the user to enter the output filename
set /p output_filename="Enter the output filename (without extension): "
REM List available audio formats
echo Select output audio format:
echo 1. WAV
echo 2. MP3
echo 3. FLAC
echo 4. AAC
echo 5. OGG
REM Prompt the user for the format choice
set /p "formatChoice=Enter the number corresponding to the desired format: "
REM Determine the chosen format
set "audio_format="
if %formatChoice%==1 set "audio_format=wav"
if %formatChoice%==2 set "audio_format=mp3"
if %formatChoice%==3 set "audio_format=flac"
if %formatChoice%==4 set "audio_format=aac"
if %formatChoice%==5 set "audio_format=ogg"
REM Validate the chosen format
if "%audio_format%"=="" (
echo Invalid choice. Exiting...
exit /b 1
)
REM Prepare the filelist.txt with the list of audio files
(for %%i in (%audio_extensions%) do (
echo file '%%i'
)) > filelist.txt
REM Merge the audio files using ffmpeg
ffmpeg -f concat -safe 0 -i filelist.txt -c copy "%output_filename%.%audio_format%"
REM Clean up temporary filelist.txt
del filelist.txt
echo All audio files merged successfully into "%output_filename%.%audio_format%"
pause
+68
View File
@@ -0,0 +1,68 @@
@echo off
title Microsoft Office Launcher
echo ------------------------------------------------------------------------------
echo Script Name: office_launcher.bat
echo Description: This script provides a menu to launch various Microsoft Office
echo applications.
echo Requirements: Microsoft Office must be installed at the specified paths.
echo Author: Nighthawk42
echo ------------------------------------------------------------------------------
:menu
echo.
echo Select an application to launch:
echo 1. Microsoft Word
echo 2. Microsoft PowerPoint
echo 3. Microsoft Outlook
echo 4. Microsoft Excel
echo 5. Microsoft OneNote
echo 6. Microsoft Access
echo 7. Microsoft Teams
echo 0. Exit
echo.
set /p choice="Enter your choice (1-7 or 0 to exit): "
if "%choice%"=="1" goto launch_word
if "%choice%"=="2" goto launch_powerpoint
if "%choice%"=="3" goto launch_outlook
if "%choice%"=="4" goto launch_excel
if "%choice%"=="5" goto launch_onenote
if "%choice%"=="6" goto launch_access
if "%choice%"=="7" goto launch_teams
if "%choice%"=="0" goto end
echo Invalid choice. Please select a number between 1 and 7 or 0 to exit.
goto menu
:launch_word
start "" "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"
goto end
:launch_powerpoint
start "" "C:\Program Files\Microsoft Office\root\Office16\POWERPNT.EXE"
goto end
:launch_outlook
start "" "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE"
goto end
:launch_excel
start "" "C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
goto end
:launch_onenote
start "" "C:\Program Files\Microsoft Office\root\Office16\ONENOTE.EXE"
goto end
:launch_access
start "" "C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE"
goto end
:launch_teams
start "" "C:\Users\%USERNAME%\AppData\Local\Microsoft\Teams\current\Teams.exe"
goto end
:end
exit
+45
View File
@@ -0,0 +1,45 @@
@echo off
setlocal EnableDelayedExpansion
echo ------------------------------------------------------------------------------
echo Script Name: youtube_rip.bat
echo Description: This script downloads audio from a specified YouTube video URL
echo and converts it to the desired format using yt-dlp. Supported formats
echo include MP3, Ogg, WAV, FLAC, and AAC.
echo Requirements: yt-dlp must be installed and available in the system's PATH.
echo Author: Nighthawk42
echo ------------------------------------------------------------------------------
REM Prompt user for YouTube URL
set /p "youtube_url=Enter YouTube URL: "
REM Prompt user for desired format
echo Choose desired format:
echo 1. MP3
echo 2. Ogg
echo 3. WAV
echo 4. FLAC
echo 5. AAC
set /p "format_choice=Enter choice (1-5): "
REM Set format according to user choice
if "%format_choice%"=="1" (
set "format=mp3"
) else if "%format_choice%"=="2" (
set "format=ogg"
) else if "%format_choice%"=="3" (
set "format=wav"
) else if "%format_choice%"=="4" (
set "format=flac"
) else if "%format_choice%"=="5" (
set "format=aac"
) else (
echo Invalid choice. Exiting.
exit /b
)
REM Call yt-dlp to download audio in specified format
yt-dlp --extract-audio --audio-format !format! "%youtube_url%"
echo Download complete.
pause