Click to See Complete Forum and Search --> : renaming files using regular expressions?


thessoro
05-30-2003, 07:23 AM
hi!
I want to know if this can be done:

In my "music" directory i have thousands of mp3 files, but they are named in a quite messing way without following any pattern.
i want them to be named as follows:

for example the file:

tHe lightning Seeds - PURE.mp3 would be ->The Lightning Seeds - Pure.mp3

That is making the first character of each word uppercase and the rest lowercase. I think maybe i can use some kind of regular expression to process them all, like a filter, using awk or some other text handling command.
Any ideas??

stolzyboy
05-30-2003, 05:33 PM
RTFM (http://www.php.net)

anyway

well you will first need to use

www.php.net/strtolower

and then use

www.php.net/ucwords

thessoro
05-31-2003, 10:32 AM
i thought this was linux/unix help and i didn't ask for a PHP solution...
i simply asked if it's possible (with a single line in the unix command-line, or using awk, sed and mv in a little bash script) to do it.
i meant, something like

mv `ls -A` `ls -A | awk someregexp`

stolzyboy
05-31-2003, 06:04 PM
well just cuz you posted it here doesn't mean it isn't a php question, maybe be more specific and say

"I want to replace file names blah, blah, blah, etc......... using
some linux commands, not php"

anyway, you could write a shell script to do it for you, and then
have a cron job run that shell script etc........