Created
August 9, 2024 19:21
-
-
Save doromones/518cdc25b8c47c7feb48a86c561265e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Define the current working directory and maximum file size (70 MB in bytes) | |
| directory_path=$(pwd) | |
| max_file_size=$((70 * 1024 * 1024)) | |
| # Iterate over all .mp3 files in the directory | |
| for file in "$directory_path"/*.mp3; do | |
| # Check if the file exists | |
| if [[ -f "$file" ]]; then | |
| # Get the file size in bytes | |
| file_size=$(stat -c%s "$file") | |
| # If the file size is greater than the maximum file size | |
| if (( file_size > max_file_size )); then | |
| # Define the output file path pattern | |
| output_file_path="${file%.mp3}_part%03d.mp3" | |
| # Use ffmpeg to split the file into 10-minute segments | |
| ffmpeg -i "$file" -f segment -segment_time 600 -c copy "$output_file_path" | |
| rm "$file" | |
| echo "File $file has been split and removed successfully."; | |
| fi | |
| fi | |
| done | |
| # directory_path=$(pwd); max_file_size=$((70 * 1024 * 1024)); for file in "$directory_path"/*.mp3; do [[ -f "$file" ]] && file_size=$(stat -f%z "$file") && (( file_size > max_file_size )) && output_file_path="${file%.mp3}_part%03d.mp3" && ffmpeg -i "$file" -f segment -segment_time 600 -c copy "$output_file_path" && rm "$file" && echo "File $file has been split and removed successfully."; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment