From 9fea10f89fe81b82381875952e8e73f4ac57b50d Mon Sep 17 00:00:00 2001 From: "Daniel M. Drucker" Date: Wed, 27 Mar 2024 08:58:51 -0400 Subject: [PATCH] bidsmerge2 --- bidsmerge2 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 bidsmerge2 diff --git a/bidsmerge2 b/bidsmerge2 new file mode 100755 index 0000000..e40bbcb --- /dev/null +++ b/bidsmerge2 @@ -0,0 +1,22 @@ +#!/bin/bash +# Extremly simplistic tool to merge one BIDS directory into another + +if [ "$#" -ne 2 ] || ! [ -d "$1" ] || ! [ -d "$2" ]; then + echo "Usage: $0 SOURCEDIR DESTDIR" >&2 + exit 1 +fi + +SOURCE=$1 +DEST=$2 + +for d in ${SOURCE} ${DEST}; do + # is this even nominally a BIDS folder? + if ! [ -e "${d}"/dataset_description.json ]; then + echo "${d} doesn't seem like a BIDS folder to me." >&2 + echo "Exiting, out of an abundance of caution." >&2 + exit 1 + fi +done + +rsync -a --remove-source-files "${SOURCE}"/ "${DEST}"/ +find "${SOURCE}" -depth -type d -empty -delete