-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_convert
More file actions
executable file
·32 lines (22 loc) · 818 Bytes
/
auto_convert
File metadata and controls
executable file
·32 lines (22 loc) · 818 Bytes
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
#!/bin/bash
set -e
set -u
ZDOTDIR="${ZDOTDIR:=$HOME/.config/zsh}"
. "$ZDOTDIR"/14_locals_bash.zsh
log="$HOME"/.tmp/log_autoconvert
convert_dir(){
dir="$@"
printf "Converting folder: %s\n" "$dir" >> "$log"
date >> "$log"
# fix permissions
chmod -R u=rwX,g=rX,o=rX "$dir"
find "$dir" -type d -iname '+' -prune -exec rm -rf --preserve-root -- '{}' \;
find "$dir" -type f -iname '*.zip' -exec rm -rf --preserve-root -- '{}' \;
# mp3 takes too much space, convert it as well
find "$dir" \( -type f -iname '*.flac' -o -iname '*.m4a' -o -iname '*.wav' -o -iname '*.wv' -o -iname '*.ape' -o -iname '*.mp3' \) -print0 |\
xargs -r -0 parallel "ffmpeg -y -i {} -b:a 96k {.}.opus && rm {}" ::: >> "$log" 2>&1
echo >> "$log"
}
for dir in "${AUTO_CONVERT_FOLDERS[@]}"; do
convert_dir "$dir"
done