From 015fd9536692409d77dceab68edadcf758399ea1 Mon Sep 17 00:00:00 2001 From: q Date: Fri, 14 Feb 2025 11:56:59 +0200 Subject: [PATCH] parse splits, rename if only one split --- files/archive-subfolders | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/files/archive-subfolders b/files/archive-subfolders index 75564d5..ab034da 100755 --- a/files/archive-subfolders +++ b/files/archive-subfolders @@ -1,6 +1,6 @@ #!/bin/bash -VERSION="20250208" +VERSION="20250214" function helpexit() { BS=$( basename "$0" ) @@ -93,6 +93,12 @@ for ((i=1; i<=${#@}; i++)) { which pv &>/dev/null || { echo pv command missing; exit 1; } if [[ -n "$SPLIT" ]]; then which split &>/dev/null || { echo split command missing; exit 1; } + if [[ "$SPLIT" =~ ^[0-9]+$ ]] || [[ "$SPLIT" =~ ^[0-9]+[KMGTPEZ]$ ]] || [[ "$SPLIT" =~ ^[0-9]+[KMGTPEZ]B$ ]]; then + true + else + echo "Cannot parse: $SPLIT. use ex. 500G. valid extension K M G T P E Z" + exit 1 + fi fi if tar --version | grep -q GNU; then SORTFILES="--sort=name" @@ -136,6 +142,13 @@ for d in "${REALFOLDERS[@]}"; do -d "$NEWEST" \ "$d.${SUFFIX}".*[0123456789] \ "$d.${SUFFIX}.lst" + shopt -s nullglob + set -- "$d.${SUFFIX}".*[0123456789] + if [[ $# -eq 1 ]]; then + echo "Split produced only one file:" + mv -v "$d.${SUFFIX}".*[0123456789] "$d.${SUFFIX}" + fi + shopt -u nullglob else touch \ -d "$NEWEST" \