Skip to content

Instantly share code, notes, and snippets.

@alexlicohen
Last active February 14, 2023 07:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexlicohen/822c05fd3d6e579ff2edd563ef52829b to your computer and use it in GitHub Desktop.
Save alexlicohen/822c05fd3d6e579ff2edd563ef52829b to your computer and use it in GitHub Desktop.
[Adding Datalad to BIDS dir] Shell commands to add Datalad subdatasets #cohenlab #shell #datalad #BIDS
#!/bin/bash
# in study dir:
# Create superdataset
datalad create -c text2git --force
for i in `ls -d sub-*`; do
if [ ! -d "${i}/.git" ]; then
# Create and register the subdataset
datalad create -c text2git --force -d . $i
fi
pushd $i
if [[ `git log --oneline | grep "Instruct annex to add text files to Git"` ]]; then
echo "procedure cfg_text2git already run"
else
datalad run-procedure cfg_text2git
fi
if [ ! -z "$(git status --porcelain)" ]; then
# Uncommitted changes
datalad save
else
# Working directory clean
echo "$i is all set"
fi
popd
done
datalad save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment