ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to create a process that renames all my filenames to Camel/Capital Case. The closest I have to getting there is this:
perl -i.bak -ple 's/\b([a-z])/\u$1/g;' *.txt # or similar .extension.
Which seems to create a backup file(which I'll remove when it's verified this does what I want); but instead of renaming the filename, it renames the text inside of the file. Is there an easier way to do this? The theory is that I have several office documents in various formats, as I'm a bit anal-retentive, and would like them to look like this:
New Document.odt
Roffle.ogg
Etc.Etc
Is this possible with perl, or do I need to change to another language/combination of them?
Also, is there anyway to make this recursive, such that /foo/foo/documents has all files renamed, as does /foo/foo/documents/foo?
Last edited by rootlinuxusr; 03-24-2009 at 10:42 AM.
Reason: recursive.
The only way this will work is to have an inclusivre, definitive rule that works on ALL filenames you intend to change. You have to be able to identify words - are they all delimited by spaces or underline characters, for example. With no delimiters in a filename you assume the filename is a single word.
What rule do you have?
BTW using spaces and shell metacharacters in filenames will cause you heartburn later on.
Guaranteed.
The only way this will work is to have an inclusivre, definitive rule that works on ALL filenames you intend to change. You have to be able to identify words - are they all delimited by spaces or underline characters, for example. With no delimiters in a filename you assume the filename is a single word.
What rule do you have?
BTW using spaces and shell metacharacters in filenames will cause you heartburn later on.
Guaranteed.
Currently they look like this:
file name.ogg
foo foo.txt
dog cat.odt
I assume that would be with spaces instead of underline? I have very, very little programming experience, but would love to learn.
Camel case is when you use capital letters for sub-words, e.g. someCamelCasedWord. So named because the letters are like the humps on a camel. Capital case (I assume) is the same, but with a capital letter at the beginning, e.g. SomeCapitalCasedWord. Camel case is the norm for variables in newer programming languages nowadays since longer variable names are expected (except in Lisp languages which prefer to use dashes to separate words). You still see underscore delimited words, but typically in older languages like C.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.