Okay, fixed it:
name=`ls | sed -n -e \$p -e "/^$STRING\$/ {" -e n -e p -e q -e \}'`
will set name to:
  the name alphabetically after $STRING if $STRING is a file in there
  which is not the last one;
  the last one if that's what $STRING is;
  the last one if $STRING is not in there at all.
There's a possible glitch if $STRING contains a period.
