summaryrefslogtreecommitdiff
path: root/tools/change-thesaurus-filenames
blob: 735791d7ab4d19a0a80bfa97e83520f65fd0615a (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /bin/sh

# In 2.0beta4 files in the Thesaurus were named <id>-<type>. E.g: 25-adminkey
# 2.0beta5 uses dots now instead of dashes: 25.adminkey

# This script reads renames files in the Thesaurus

# It is assumed that the largest id in use is 999

set -e

FILES=`ls [0-9]-conf [0-9]-key [0-9]-stats [0-9]-help [0-9]-adminkey [0-9][0-9]-conf \
          [0-9][0-9]-key [0-9][0-9]-stats [0-9][0-9]-help [0-9][0-9]-adminkey \
          [0-9][0-9][0-9]-key [0-9][0-9][0-9]-stats [0-9][0-9][0-9]-help [0-9][0-9][0-9]-adminkey 2>/dev/null` || true

if [ -z "$FILES" -a -d "results/thesaurus/" ]; then
	echo Changing to directory results/thesaurus/
	cd results/thesaurus/
	FILES=`ls [0-9]-conf [0-9]-key [0-9]-stats [0-9]-help [0-9]-adminkey [0-9][0-9]-conf \
		  [0-9][0-9]-key [0-9][0-9]-stats [0-9][0-9]-help [0-9][0-9]-adminkey \
		  [0-9][0-9][0-9]-key [0-9][0-9][0-9]-stats [0-9][0-9][0-9]-help [0-9][0-9][0-9]-adminkey 2>/dev/null` || true
fi
if [ -z "$FILES" -a -d "thesaurus/" ]; then
	echo Changing to directory thesaurus/
	cd results/thesaurus/
	FILES=`ls [0-9]-conf [0-9]-key [0-9]-stats [0-9]-help [0-9]-adminkey [0-9][0-9]-conf \
		  [0-9][0-9]-key [0-9][0-9]-stats [0-9][0-9]-help [0-9][0-9]-adminkey \
		  [0-9][0-9][0-9]-key [0-9][0-9][0-9]-stats [0-9][0-9][0-9]-help [0-9][0-9][0-9]-adminkey 2>/dev/null` || true
fi

if [ -z "$FILES" ]; then
	echo "Could not find any old style filenames in '.', 'results/thesaurus/', or 'thesaurus/'" >&2
	exit 1
fi

echo "Renaming files..."
for file in $FILES ; do
	mv $file `echo $file | tr '-' '.'`
done

echo "done."
echo "The next buildthesaurus run (per default every hour) will fix the index file"