What language for simple util script?

Started by
4 comments, last by OrangyTang 19 years, 11 months ago
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.
Advertisement
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.
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
- Jason Citron- Programmer, Stormfront Studios- www.stormfront.com
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?
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.
SciTE is a nice cross-platform text editor that has syntax hilighting for python.

This topic is closed to new replies.

Advertisement