Burn My Time

~Josh Houghtelin

File rearranging script.

Josh Houghtelin C++, Tech, Work, Code

The huge downfall of scripting languages (for me) is that they require every computer they are run on to have the interpreter installed or I have to jump through a hundred loops to get the script to compile as an executable. For that reason (and because I have two weeks of downtime now) I am porting as many of my scripts as I can over to C/C++. I just spent the last 4 hours (I know, I’m lame) hacking together the most frequently used script. *drum role please* Here it is.

GEMS File Rearranging Script.

What it does: In all simplicity it just moves and renames files. We have to produce audio for the blind people who vote on the touch screen voting equipment. It’s easiest for us to label it like so:

R10.wav — the race audio w/10 being the race ID number.
R10_10.wav – the first candidate w/10 being the candidate ID number.
R10_20.wav – the second candidate w/20 being the candidate ID number.

This allows us to keep everything in order and burn audio CD’s to ship to our customers so they can proof the audio for pronunciation and whatnot. All in all having everything ordered like that just makes our life 100x easier. The script which was initially 15 lines of PHP simply rearranged all the audio so GEMS (the proprietary software used to program the machines for the election) could import the audio. It goes a little something like this:

R10.wav – stays the same.
R10_10.wav – this gets changed to 10.wav and gets placed in the newly created folder 10. The folder represents the race id number and the filename within it represents the candidate ID.
R10_20.wav – this gets changed to 20.wav and gets placed in folder “10”. And so on.

Here is the source code.
Here is the binary compiled by Bloodshed Dev-C++.

I’m far from a C coder so don’t be too much of an asshole if you see how bad my code is. Some constructive criticism would be nice though. I know I completely slaughtered the source but it’s cool to have an interperter independant executable. If you are good at C/C++ I would realy enjoy seeing how your source code for this would work.

One script down.. A whole shitload to go.

2 comments

I don’t have time right now to help you with all that needs to be fixed with that but right off the bat fix the system(”PAUSE”). That is the equivalent of stopping a kid on a big wheel with a low yield nuclear weapon. In short it’s overkill. Use getchar instead.

Posted by Andy, on August 14th, 2006, às 8:11 pm. #.

Actualy. I just took it out entirely becuase the executable doesn’t need to stop anymore now that it works. I just posted the most recent one. I’ll remember that though.

Don’t waste your time to review that hacked together thing. Especialy if your tight on time. Wait until I post something a little bit more intelligent. =)

Thanks man.

Posted by Josh Houghtelin, on August 14th, 2006, às 8:34 pm. #.

Leave a comment!



Message



Burn My Time © 2007.

Simple Grey theme developed by Rodrigo P. Ghedin.
Brought by Wordpress Themes

WordPressFAMFAMFAM