mirror of
https://github.com/opensiriusfox/bashrc.d.git
synced 2025-06-16 20:31:15 -07:00
tweaked to remove some old junk, and add rust
This commit is contained in:
parent
5748a2178e
commit
569bedc92b
5 changed files with 15 additions and 12 deletions
20
archive/1-parallel-template
Normal file
20
archive/1-parallel-template
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
MAX_JOBS=8
|
||||
function holdForWork() {
|
||||
while [[ $MAX_JOBS -le $(jobs -l | wc -l) ]]; do sleep 0.1; done
|
||||
}
|
||||
function holdForFinish() {
|
||||
while [[ $(jobs -lr | wc -l) -gt 0 ]]; do sleep 0.1; done
|
||||
}
|
||||
|
||||
|
||||
for TASK in TASK_LIST; do
|
||||
holdForWork
|
||||
(
|
||||
echo ""
|
||||
) &>/dev/null &
|
||||
done
|
||||
|
||||
holdForFinish
|
||||
echo " ...done!"
|
43
archive/ffmpegBatch.sh
Normal file
43
archive/ffmpegBatch.sh
Normal file
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
function batchConvertFLAC() {
|
||||
IFS=$'\n'
|
||||
INPUT_EXT="${1:-.flac}"
|
||||
INPUT_DIR="${2:-./}"
|
||||
OUT_DIR="${3:-./output}"
|
||||
if [[ "${INPUT_DIR: -1}" != "/" ]]; then
|
||||
INPUT_DIR="$INPUT_DIR/"
|
||||
fi
|
||||
if [[ "${OUT_DIR: -1}" != "/" ]]; then
|
||||
OUT_DIR="$OUT_DIR/"
|
||||
fi
|
||||
|
||||
if [[ ! -e "$OUT_DIR" ]]; then
|
||||
mkdir -pv "$OUT_DIR"
|
||||
fi
|
||||
|
||||
jMax=${JOBS:-4};
|
||||
|
||||
pids=()
|
||||
FROM="$(readlink -f "$INPUT_DIR")/"
|
||||
TO="$(readlink -f "$OUT_DIR")/"
|
||||
(
|
||||
cd "$FROM"
|
||||
for FLAC in *$INPUT_EXT; do
|
||||
echo "Converting '$INPUT_DIR$FLAC'..."
|
||||
while [[ "$(jobs -r | wc -l)" -ge $jMax ]]; do
|
||||
sleep 0.1
|
||||
done
|
||||
IN_FILE="$FLAC"
|
||||
OUT_FILE="$TO${FLAC/.flac/.m4a}"
|
||||
#echo "$OUT_FILE"
|
||||
ffmpeg -i "$IN_FILE" -n -ab 192k -vn "$OUT_FILE" &>/dev/null &
|
||||
pids[${i}]=$!
|
||||
done
|
||||
for PID in ${pids[@]}; do
|
||||
wait $PID
|
||||
done
|
||||
echo "done."
|
||||
)
|
||||
}
|
||||
#complete -F _minimal batchConvert
|
Loading…
Add table
Add a link
Reference in a new issue