From c8f0298bebf62fbc05bd7ce1df99c8138ca0d9db Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Tue, 7 Nov 2023 16:48:09 +0100 Subject: [PATCH] fixing fix sanitize_folder.sh --- nixos/components/media/sanitize_folder.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nixos/components/media/sanitize_folder.sh b/nixos/components/media/sanitize_folder.sh index 0e75166..2bc2d35 100644 --- a/nixos/components/media/sanitize_folder.sh +++ b/nixos/components/media/sanitize_folder.sh @@ -1,20 +1,19 @@ -#! /bin/bash +#!/bin/bash # todo : add a dry-run sanitize() { - shopt -s extglob; + shopt -s extglob filename=$(basename "$1") directory=$(dirname "$1") filename_clean="${filename//+([^[:alnum:]_-\\.])/_}" - if (test "$filename" != "$filename_clean") - then + if [[ $filename != "$filename_clean" ]]; then mv -v --backup=numbered "$1" "$directory/$filename_clean" fi } export -f sanitize -find $1 -depth -exec bash -c 'sanitize "$0"' {} \; +find "$1" -depth -exec bash -c 'sanitize "$0"' {} \;