Qbix: #!/bin/sh
for i in *
do
text = `head -n1 $i`
mv $i "$text.txt"
done
Interesting, whenever I've needed to do that I've always just used xargs. And I'd probably make use of sed to ensure that the filename ended up being something of reasonable length.
Wishbone: Yeah, I'd definitely write some sort of script to do that. Of course, you have to take into account that the first line of text may contain characters that cannot legally be part of a file name.
If it's genuinely a text document in use by a Canadian, then it shouldn't be the case.
Throwing in something like this: sed 's/[!@#\$%^&*()]//g' to a pipe would clear most of that up. Which is probably why I end up using xargs so often as it allows me to do stuff like that without too much trouble.