-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove_track.sh
49 lines (40 loc) · 1.47 KB
/
remove_track.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# remove_track.sh - A simple script to remove a specific track from MKV files
#
# This script loops through all MKV files in the current directory, lists their tracks,
# and allows the user to select a track (video, audio, or subtitle) to remove.
# After processing, the original MKV file is replaced with the updated version.
#
# Dependencies:
# - mkvmerge (from MKVToolNix)
#
# Usage:
# 1. Place this script in the folder containing your MKV files.
# 2. Run `chmod +x remove_track.sh` to make it executable.
# 3. Execute the script: `./remove_track.sh`
# 4. Follow the prompts to remove tracks as needed.
#
# Author: [Your Name]
# License: MIT
# Loop through all MKV files in the current directory
for file in *.mkv; do
echo "Processing: $file"
# List tracks in the MKV file
mkvmerge -i "$file"
# Prompt user to enter the track ID to remove
read -p "Enter the track ID you want to remove (or press Enter to skip): " track
# Check if user provided a valid input
if [[ -n "$track" ]]; then
# Temporary output file
temp_file="${file%.mkv}_modified.mkv"
# Run mkvmerge to remove the selected track
mkvmerge -o "$temp_file" -T -d "!$track" -a "!$track" -s "!$track" "$file"
# Replace the original file
mv "$temp_file" "$file"
echo "Updated: $file (Track $track removed)"
else
echo "Skipping $file"
fi
echo "-----------------------------------"
done
echo "All files processed."