From 980fa702011ceb5783c3ca153d2841a6d3a25871 Mon Sep 17 00:00:00 2001 From: Alec <30010253+alec-glisman@users.noreply.github.com> Date: Mon, 8 Apr 2024 20:46:10 -0700 Subject: [PATCH] Add script for moving data from local to local directory --- .../move_data_from_local_to_local.sh | 32 +++++++++++++++++++ ...l.sh => move_data_from_remote_to_local.sh} | 9 +++--- 2 files changed, 36 insertions(+), 5 deletions(-) create mode 100755 scripts/maintenance/move_data_from_local_to_local.sh rename scripts/maintenance/{move_data_from_zeal_to_local.sh => move_data_from_remote_to_local.sh} (79%) diff --git a/scripts/maintenance/move_data_from_local_to_local.sh b/scripts/maintenance/move_data_from_local_to_local.sh new file mode 100755 index 0000000..6ec578c --- /dev/null +++ b/scripts/maintenance/move_data_from_local_to_local.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# -*- coding: utf-8 -*- +# Created by Alec Glisman (GitHub: @alec-glisman) on February 2nd, 2023 +# + +# built-in shell options +set -o errexit # exit when a command fails. Add || true to commands allowed to fail +set -o nounset # exit when script tries to use undeclared variables + +# data I/O directories +source_dir='/nfs/zeal_nas/home_mount/aglisman/GitHub/Polyelectrolyte-Surface-Adsorption/data_archive/6_single_chain_binding/cleaned' +dest_dir='/nfs/zeal_nas/data_mount/aglisman-data/1-electronic-continuum-correction/7-single-chain-surface-binding' + +# ########################################################################## # +# Move data to new directory with rsync # +# ########################################################################## # + +# prompt user to accept or reject moving files +echo "INFO) Moving files to new directory" +echo "DEBUG) Source directory: ${source_dir}" +echo "DEBUG) Destination directory: ${dest_dir}" +read -p "Do you want to move files from the source to the destination directory? (y/n) " -n 1 -r +echo +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "INFO) Not moving files" +else + echo "INFO) Moving files" + rsync --verbose --archive --progress --human-readable --relative --stats \ + "${source_dir}/." "${dest_dir}/" +fi + +echo "INFO) Done" diff --git a/scripts/maintenance/move_data_from_zeal_to_local.sh b/scripts/maintenance/move_data_from_remote_to_local.sh similarity index 79% rename from scripts/maintenance/move_data_from_zeal_to_local.sh rename to scripts/maintenance/move_data_from_remote_to_local.sh index 135ae47..7218190 100755 --- a/scripts/maintenance/move_data_from_zeal_to_local.sh +++ b/scripts/maintenance/move_data_from_remote_to_local.sh @@ -10,8 +10,8 @@ set -o nounset # exit when script tries to use undeclared variables # data I/O directories remote_address='aglisman@zeal.caltech.edu' remote_dir='/nfs/zeal_nas/home_mount/aglisman/GitHub/Polyelectrolyte-Surface-Adsorption/data_archive/6_single_chain_binding/cleaned' -local_dir='/Volumes/ExFat/single_chain_binding' -pattern='*/2-concatenated/*' +local_dir='/Users/alecglisman/Downloads/single_chain_binding' # '/Volumes/ExFat/single_chain_binding' +pattern='*/3-sampling-opes-one/replica_00/2-concatenated/*' # ########################################################################## # # Move data to new directory with rsync # @@ -27,9 +27,8 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "INFO) Not moving files" else echo "INFO) Moving files" - rsync --archive --verbose --progress --human-readable --dry-run \ - --include="${pattern}" --exclude="*" \ - "${remote_address}:${remote_dir}/" "${local_dir}/" + rsync --verbose --archive --progress --human-readable --relative --stats \ + "${remote_address}:${remote_dir}/./${pattern}" "${local_dir}/" fi echo "INFO) Done"