This commit is contained in:
Para Dox
2025-04-27 17:47:25 +07:00
parent 4b17d54280
commit 9f3710ddaa

View File

@@ -93,8 +93,8 @@ for group_name in "${group_names[@]}"; do
filename=$(basename "$base")
if [[ "$filename" == *"_0_499999" ]]; then
# Check if the key for this base path is already set in files_to_keep
# Use -v for safe check with set -u
if ! [[ -v files_to_keep[$base] ]]; then
# Use parameter expansion ${key+x} for safe check with set -u (Bash 4.0+)
if [[ -z "${files_to_keep[$base]+x}" ]]; then
echo "Marking first range '$filename' to keep for group '$group_name'."
files_to_keep["$base"]=1 # Mark this base path for keeping
first_range_kept=true
@@ -121,8 +121,8 @@ for group_name in "${group_names[@]}"; do
base="${sorted_bases[$i]}" # Get the base path from the sorted array
filename=$(basename "$base")
# Mark for keeping only if it hasn't been marked already (e.g., by Rule 1)
# Use -v for safe check with set -u
if ! [[ -v files_to_keep[$base] ]]; then
# Use parameter expansion ${key+x} for safe check with set -u (Bash 4.0+)
if [[ -z "${files_to_keep[$base]+x}" ]]; then
echo " - $filename"
files_to_keep["$base"]=1 # Mark this base path for keeping
else
@@ -138,8 +138,8 @@ for group_name in "${group_names[@]}"; do
# Iterate through all sorted base paths for the group
for base in "${sorted_bases[@]}"; do
# If a base path is NOT marked to be kept (key doesn't exist in files_to_keep), move it
# Use -v for safe check with set -u
if ! [[ -v files_to_keep[$base] ]]; then
# Use parameter expansion ${key+x} for safe check with set -u (Bash 4.0+)
if [[ -z "${files_to_keep[$base]+x}" ]]; then
files_to_move+=("$base") # Add base path to the list of files to move
fi
done