Archived

This topic is now archived and is closed to further replies.

OrangyTang

What language for simple util script?

Recommended Posts

OrangyTang    1298
Long story short: my second HD died on me in as many months, due to a weird problem with my particular combination of mobo & HD type. File recovery is semi-possible, by the rather roundabout way of using an NTFS-to-FAT low-level file copier, and then back to NTFS in windows. However that has the rather unfortunate side effect of truncating all my filenames to 8.3 format. I can manually convert most back, but I''ve got lots (100+) of Java source files that need renaming. For anyone that doesn''t know, Java source files have a strict path & naming convention - they must be named the same as the public class they contain, and the directory structure mimics the package (namespace) declaration. So all the information needed for a rename is sitting in the files themselves! I could probably do it without too much hastle in C++ or Java, but I decided to take the oppertunity to try some other higher level language. I''m thinking either Python (''cos I''ve been meaning to look into it for ages) or PHP (since I''m planning some PHP web stuff at some point). Does anyone have any recommendations to one or the other to try? Perhaps another language that would be easier to do this in? And any handy IDE type stuff as well would be appreciated. Thanks.

Share this post


Link to post
Share on other sites
GnuVince    259
Yeah, Python would be a clear choice. Easy like hell to do too. Just read the whole file, take the line that starts with ''package'', split at the space, take the second element of that list, remove the semi-colon (now you have your name) and rename the file to the name you found and add .java. Pretty easy to do, I''d say about 8-10 lines.

Share this post


Link to post
Share on other sites
Clash    342
Huzzah for Perl!

If you''re not too interested in Python, or simply want to try something else, then Perl is definitely worth looking at for text parsing. The language has built in support for Regular Expressions which are mmm mmm good.

http://www.perl.com/

- Jason Citron
- Team nine:14, System Architect
- www.fatesforgiven.com

-------------------------
Check out screenshots of the Fates Forgiven Alpha at www.fatesforgiven.com/screenshots

Share this post


Link to post
Share on other sites
OrangyTang    1298
Perl probably would be a good choice, as I''ve used some perl in the past to do server-side generation of web pages (and its text parsing is rather good ). However I''m kinda looking for an excuse to tinker with something new.

Looks like it''ll be Python then. Anyone have any particular recomendations for a text editor / small IDE for use with it?

Share this post


Link to post
Share on other sites
Interim    122
Textedit has color syntax for just about every language.

Also, if you choose Python (ActiveState or the Win32 Python) you''ll get a free IDE to work with Python (written in Python).

Interim.

Share this post


Link to post
Share on other sites