blob: 3a00564998696df47e800c5697a80b536df86779 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/bin/sh
# Remove whitespaces in all filenames in a given directory
if [ "$#" -gt 1 ]; then
echo "Usage: rmw <dir>" >&2
exit 1
fi
if [ "$#" -eq 0 ]; then
dir="$(pwd)"
else
dir="$1"
fi
cd "$dir" || {
echo "Couldn't cd to directory. Exiting..." >&2
exit 1
}
for file in "$dir"/*; do
newname="$(echo "$file" | sed -e 's/["`”“-]*//g' -e 's/[ \t]+/\_/g')"
mv "$file" "$newname"
done
exit 0
|