diff --git a/scripts/hlcp b/scripts/hlcp new file mode 100755 index 0000000..e76c75a --- /dev/null +++ b/scripts/hlcp @@ -0,0 +1,45 @@ +#!/bin/bash + +SRC=$1 +TRGET=$2 + +HEADTREE=75 +TAILTREE=1 + +if ! [[ -d $SRC ]]; then + echo "$SRC is not a directory" + exit 1 +fi + +if ! [[ -d $TRGET ]]; then + echo "$TRGET is not a directory" + exit 1 +fi + + +TREEFILE=$(mktemp -t treefile) +tree -ha --du "$SRC" >> $TREEFILE +if [ $(cat $TREEFILE | wc -l) -gt $[TAILTREE + HEADTREE] ]; then + head -${HEADTREE} $TREEFILE + echo ... + tail -${TAILTREE} $TREEFILE + echo Full tree in $TREEFILE +else + cat $TREEFILE +fi + + + + + +pushd $SRC + +FINDSTART=`date +%s` +find . -type d -exec bash -c "mkdir -p \"${TRGET}{}\"" \; +DIREND=`date +%s` +find . -type f -exec bash -c "ln -h \"{}\" \"${TRGET}{}\"" \; +LNEND=`date +%s` + +echo dirtime $((DIREND-FINDSTART))s +echo linktime $((LNEND-DIREND))s +echo alltime $((LNEND-FINDSTART))s diff --git a/scripts/torrentname b/scripts/torrentname new file mode 100755 index 0000000..30371f3 --- /dev/null +++ b/scripts/torrentname @@ -0,0 +1,34 @@ +#!/bin/bash + +TFE="/Applications/Torrent\ File\ Editor.app/Contents/MacOS/Torrent\ File\ Editor" +TMPJSON=$(mktemp) +BASEDIR="tfefix" + + +for TORRENTFILE in $@ +do + eval $TFE --to-json $TORRENTFILE $TMPJSON + + NAME=$(jq -r ".info.name" $TMPJSON) + ANNOUNCE=$(jq -r ".announce" $TMPJSON) + +# ANNOUNCE=$(echo $ANNOUNCE | grep -o '\:[^$]*\:' | tr -d ':') +# ANNOUNCE="${ANNOUNCE:2}" + + ANNOUNCE=$(echo $ANNOUNCE | awk -F/ '{print $3}') + if [ -z "$ANNOUNCE" ]; then + ANNOUNCE="noannounce" + fi + echo "${TORRENTFILE} => ${NAME}" + DIR="${BASEDIR}" + + if [ -n "$ANNOUNCE" ]; then + DIR="${BASEDIR}/${ANNOUNCE}" + fi + + mkdir -p "$DIR" + cp "$TORRENTFILE" "${DIR}/${NAME}.torrent" +# cat $TMPJSON + + rm $TMPJSON +done