Skip to content

Instantly share code, notes, and snippets.

@1stvamp
Last active April 28, 2020 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1stvamp/966b97e12b98ab4a047003f2290d3c2a to your computer and use it in GitHub Desktop.
Save 1stvamp/966b97e12b98ab4a047003f2290d3c2a to your computer and use it in GitHub Desktop.
Recursive whisper data file back-fill script using carbonate::whisper-fill
#!/bin/bash
set -eo pipefail
if [ "$#" -lt 2 ]
then
>&2 echo 'Usage: whisper-back-fill.sh SOURCE_BASE_DIR DESTINATION_BASE_DIR'
>&2 echo 'e.g. given './data/dal05': whisper-back-fill.sh ./data /data/graphite/storage/'
exit 1
fi
SOURCE_DIR="$1"
DEST_DIR="$(realpath -s "$2")"
shopt -s globstar nullglob
for FILE in "${SOURCE_DIR}"/**/*.wsp
do
DEST_PATH="${DEST_DIR}/${FILE}"
if [ -f "${DEST_DIR}/${FILE}" ]
then
whisper-fill "${FILE}" "${DEST_PATH}"
else
mkdir -p "$(dirname "${DEST_PATH}")"
cp "${FILE}" "${DEST_PATH}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment