Skip to content

Commit

Permalink
[FIX] Address mulitple special chars in uploaded data
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Levitas committed Jun 20, 2024
1 parent 7d7b0d2 commit b3ef590
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions handler/preprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ fi
root=$1
echo "running preprocess.sh on root folder ${root}"

echo "replace file paths that contain spaces or [@^()] characters"
find $root -depth -name "*[ @^()]*" | parallel --linebuffer -j 6 -execdir rename "'s/[ @^()]/_/g'" "{}" \;
echo "replace file paths that contain space, quotation, or [@^()] characters"
find "$root" -depth -name "*[ @^()]*" -print0 | sort -rz | xargs -0 -n 1 -I {} ./rename_special_chars.sh {}

echo "running expand.sh"
./expand.sh $root
Expand Down
11 changes: 11 additions & 0 deletions handler/rename_special_chars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
file="$1"
dir=$(dirname "$file")
base=$(basename "$file")
new_base=$(echo "$base" | sed 's/[ @^()]/_/g')
new_file="$dir/$new_base"

if [[ "$file" != "$new_file" ]]; then
echo "Renaming '$file' to '$new_file'"
mv "$file" "$new_file"
fi

0 comments on commit b3ef590

Please sign in to comment.