hardlink copy + torrentfixname
This commit is contained in:
parent
117a188659
commit
051aed99f3
45
scripts/hlcp
Executable file
45
scripts/hlcp
Executable file
@ -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
|
||||
34
scripts/torrentname
Executable file
34
scripts/torrentname
Executable file
@ -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
|
||||
Loading…
Reference in New Issue
Block a user