summaryrefslogtreecommitdiff
path: root/rmw
blob: 37a2504a5dd7f8f1fdc9dd6fd16b38b7023a0f77 (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 the files 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