PDA

View Full Version : GREP question




harleytat
Mar 4, 2005, 06:12 PM
I'm using A Better Finder Rename to rename a bunch of files in this format: SampleFileName

I'd like them to look like this: sample file name

I've gotten this far in my grep adventures, which selects the first (capitalized) word: ([AB][a-z]*) but I can't figure out how to define the subsequent words.

first one with the answer gets good karma!

thanks a lot
H



martintyler
Mar 5, 2005, 04:04 AM
Sorry, not a complete answer, but...

echo "SampleFileName" | sed 's,\([A-Z]\)\([a-z]*\)\([A-Z]\)\([a-z]*\)\([A-Z]\)\([a-z]*\),\1\2 \3\4 \5\6,1'| tr 'A-Z' 'a-z'
sample file name

broken_keyboard
Mar 5, 2005, 08:11 AM
ls | perl -e 'while (<>) { chomp; $old = $_; s/([^A-Z])([A-Z])/$1 $2/g; $new = lc($_); `mv "$old" "$new"`}'

AtlantaGuy
Mar 5, 2005, 09:31 AM
- GREP without the hassles
http://www.espgraphics.com/poirot/

yellow
Mar 5, 2005, 12:38 PM
Not an answer to your question..

But I found that ABFR sucked. It didn't do what it advertised at all and the developers didn't do jack to help me try and correct it (I was trying to do something fairly simple afterall).

Ultimately, I settled on Filenamer (http://www.macupdate.com/info.php/id/14423).

harleytat
Mar 5, 2005, 02:43 PM
broken keyboard...pure genius. you saved me mucho time. just tried it on a small batch and it worked flawlessly...now gonna toss it at the 1200 other files.

thanks all else for the software recs. am downloading and checking them out as we speak.

H