fixing fix sanitize_folder.sh
This commit is contained in:
parent
07d807c4db
commit
c8f0298beb
1 changed files with 4 additions and 5 deletions
|
@ -1,20 +1,19 @@
|
||||||
#! /bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# todo : add a dry-run
|
# todo : add a dry-run
|
||||||
|
|
||||||
sanitize() {
|
sanitize() {
|
||||||
shopt -s extglob;
|
shopt -s extglob
|
||||||
|
|
||||||
filename=$(basename "$1")
|
filename=$(basename "$1")
|
||||||
directory=$(dirname "$1")
|
directory=$(dirname "$1")
|
||||||
|
|
||||||
filename_clean="${filename//+([^[:alnum:]_-\\.])/_}"
|
filename_clean="${filename//+([^[:alnum:]_-\\.])/_}"
|
||||||
|
|
||||||
if (test "$filename" != "$filename_clean")
|
if [[ $filename != "$filename_clean" ]]; then
|
||||||
then
|
|
||||||
mv -v --backup=numbered "$1" "$directory/$filename_clean"
|
mv -v --backup=numbered "$1" "$directory/$filename_clean"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
export -f sanitize
|
export -f sanitize
|
||||||
find $1 -depth -exec bash -c 'sanitize "$0"' {} \;
|
find "$1" -depth -exec bash -c 'sanitize "$0"' {} \;
|
||||||
|
|
Loading…
Reference in a new issue