Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#164565 - 07/06/2003 14:50 Moving odd filenames in a bash script
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
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

Top
#164566 - 07/06/2003 15:01 Re: Moving odd filenames in a bash script [Re: drakino]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Always fun.

Instead of putting underscores in front of the spaces, put quotes around the whole argument. (mv "space name" spacename)

As for filenames that start with hyphens, try just making the first argument to mv be ``--'', which tells most versions to stop interpreting things as options. (mv -- -test test)
_________________________
Bitt Faulk

Top