#!/usr/bin/tcl
#
# halfd will only allow votes on maps that are all lower-case.
#
# This script will rename all BSP files to lower-case.  run this from your maps/
# directory!
#
if [catch {glob -nocomplain "*.bsp" "*.BSP"} files] {
	echo "Error looking for *.bsp: $files"
}

if [lempty $files] {
	echo "No *.bsp or *.BSP files found!"
	exit 0
}

echo "Found [llength $files] files to rename."

set i 0
puts -nonewline "Renaming..."
foreach file $files {
	set newfile [string tolower $file]
	if [cequal $file $newfile] continue
	if [catch {file rename $file $newfile} err] {
		puts stderr "Error renaming $file to $newfile: $err"
	}
	incr i
	if ![expr $i % 10] { puts -nonewline "." }
}
echo "Done."
