Changing the format and arrangement of a text file

Is there a way to use applescript to convert a text file with a list like this…

BSmith
JDoe
TAnderson

… to this…

bsmith
jdoe
tanderson

Any ideas?

Searching the forum as well as Code Exchange, ScriptBuilders, or even Apple’s AppleScript site (in particular, see the Essential Sub-Routines), will result in many solutions for searching and replacing text as well as case transformation. That said, this works:

set the_string to "BSmith<space><space><space><space> 
JDoe<space><space><space><space> 
TAnderson<space><space><space><space>"
--this is for demo purposes, in your actual script, use:
--set the_string to read file "path:to:file"

set old_atid to AppleScript's text item delimiters
set the_string to snr(the_string, "<space>", "")
atid(old_atid)
set the_string to change_case(the_string, "lower", true)
return the_string --you could write this back to the original file, a new file, or use it as is

on atid(the_delim)
	set AppleScript's text item delimiters to the_delim
end atid

on snr(the_string, search_string, replace_string)
	return my list_to_string((my string_to_list(the_string, search_string)), replace_string)
end snr

on string_to_list(the_string, the_delim)
	my atid(the_delim)
	set the_list to (every text item of the_string) as list
	my atid("")
	return the_list
end string_to_list

on list_to_string(the_list, the_delim)
	my atid(the_delim)
	set the_string to (every text item of the_list) as string
	my atid("")
	return the_string
end list_to_string

property letters_uc : (characters of "ABCDEFGHIJKLMNOPQRSTUVWXYZ???")
property letters_lc : (characters of "abcdefghijklmnopqrstuvwxyz???")
property letters_dia_uc : (characters of "                    ")
property letters_dia_lc : (characters of "                    ?")
property letters_nondia_uc : (characters of "AAAAAACEEEEIIIINOOOOOUUUUY")
property letters_nondia_lc : (characters of "aaaaaaceeeeiiiinooooouuuuy")

on change_case(the_string, convert_case, strip_diacriticals)
	if strip_diacriticals = true then
		set letters_dia_uc_replace to letters_nondia_uc
		set letters_dia_lc_replace to letters_nondia_lc
	else
		set letters_dia_uc_replace to letters_dia_uc
		set letters_dia_lc_replace to letters_dia_lc
	end if
	if convert_case = "lower" then
		set search_chars to letters_uc & letters_dia_uc
		set replace_chars to letters_lc & letters_dia_lc_replace
	else
		set search_chars to letters_lc & letters_dia_lc
		set replace_chars to letters_uc & letters_dia_uc_replace
	end if
	set return_string to ""
	repeat with i from 1 to (count of characters of the_string)
		set string_char to (character i of the_string)
		if search_chars contains string_char then
			repeat with j from 1 to (count of search_chars)
				if (item j of search_chars) = string_char then
					set return_string to return_string & (item j of replace_chars)
					exit repeat
				end if
			end repeat
		else
			set return_string to return_string & string_char
		end if
	end repeat
	return return_string as string
end change_case

Jon