-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpawn-B-Gone.sh
More file actions
52 lines (42 loc) · 1.79 KB
/
Spawn-B-Gone.sh
File metadata and controls
52 lines (42 loc) · 1.79 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Spawn-B-Gone v1.0
# (c) Dec 2019 Kelly Lawrence
#############
# Variables #
#############
bspCount=`ls -1 *.bsp 2>/dev/null | wc -l`
polypTarget="monster_polyp"
polypReplacement="monster_abcde"
spawnTarget="monster_tarbaby"
spawnReplacement="monster_rotfish"
# Check if Perl/Grep is installed
if command -v perl > /dev/null 2>&1 && command -v grep > /dev/null 2>&1
then
# See if there are any .bsp files in the current directory
if [ $bspCount != 0 ]
then
# Loop through all map files
for map in *.bsp ;
do
# If $spawnTarget reference exists in map file
if strings $map | grep "$spawnTarget" > /dev/null 2>&1
then
# Create a backup of the original map file
echo "$spawnTarget found in $map. Creating backup of map file."
cp $map $map.bak
# Replace $spawnTarget references with $spawnReplacement
echo "Replacing $spawnTarget with $spawnReplacement in $map"
perl -pi -e 's/'$spawnTarget'/'$spawnReplacement'/g' $map
# No $spawnTarget references in $map file
else
echo "No references of $spawnTarget found in $map"
fi
done
# No .bsp files could be found
else
echo "No .bsp files could be found in the current directory."
fi
# Perl and/or Grep is not installed
else
echo "Please install Perl (https://www.perl.org) and/or GREP (http://gnuwin32.sourceforge.net/packages/grep.htm) to run this script."
fi