I have a script on my Linux machine that automaticially processes new backgrounds that I throw into a directory. I found two problem filenames today, and am not quite sure how to deal with them in a bash script.

First problem is a file with spaces. I've been playing with the command TR to try and replace the blank spaces with underscores, but I can't figure out how to add a \ before every blank space for the first parameter of mv.

Second problem is a file starting with a -. Same problem as above, I can get TR to replace the dashes with underscores, but can't figure out how to escape the filename for the first parameter for move.

Maybe the best question beyond these two scenarios would be to ask for an all purpose way of renaming a file to have no spaces and no non-alphernumeric characters.

Thanks