Tuesday, December 20, 2005

I'm thinking, I'm thinking!

But in the mean time, here is a contest: a signed print of any photo from our collection to the first person who can identify what this piece of code (which I wrote and run daily at home) does. (Second prize is two photos)

d=Dir.new(".")
flac_fns = Array.new
wav_fns = Array.new
d.each {|x|
if x =~ /\.flac/
flac_fns.push(x)
elsif x=~ /\.wav/
wav_fns.push(x)
end
}

high_num = flac_fns.length

wav_fns.each {|i|
high_num = high_num + 1
`move \"#{i}\" \"#{i.sub(/\d+/,high_num.to_s)}\"`
}

To be eligible for this contest, you have to be someone other than a male whose last name is Settergren or someone younger than 25 or older than 36.

You don't have to be baptized as an infant to be eligible.

BTW I am seriously considering finding a different (better) free blog service. This thing can't even handle leading spaces - which makes the code even harder to read. Any suggestions for a better blog service?

9 comments:

Anonymous said...

You can edit the raw HTML, so you should be able to do anything! The "pre" (for PREformatted) appears to be what you want. Blogger won't let me demonstrate raw HTML within this comment box, but try clicking on "son1" up there.

Anonymous said...

Another suggestion: you could build a custom Perl (or Ruby) script to convert raw text (code) to equivalent HTML, but the same functionality basically exists as part of POD (Plain Old Documentation):

Paste your text (indentations and all -- make sure all lines are indented by at least one space) into an empty text document, say pod.txt. Prepend with some POD keywords (with extra blank lines):

=dummy

your
stuff
(all
starting
with
whitespace

=cut

And then run "pod2html.pl pod.txt > pod.html" (pod2html.pl is part of your Perl install)

Anonymous said...

I know what it doesn't do. It's not the algorithm you use to make your weekly football picks. :)

Anonymous said...

You use it to search for new music files (.wav and .flac) and move them into a new directory.

Bruce S said...

Do you really want an autographed photo? The fact is you are in the right ball park but you are missing the real gist and it is because you are tripping over the 'move' command.

I will give the Settergren boys a shot and if they don't get it by COB tomorrow, you can have the first prize based on effort. (Do we need to get you a charge number for this?)

On Saturday, I will come out with the line by line comments.

Anonymous said...

If this was thin air stuff I would have figured it out by now. Ok, one last guess. You're using it to play the music.

Anonymous said...

It looks to me like you have .flac files (what's a .flac file? Is it an audio recording of a yelling duck?) and .wav files. The .wav files, and presumably also the .flac files, have numbers in their names, but you don't want to reuse the numbers, so you rename all of the .wavs. But if you get one more .flac, that messes up the whole scheme, so this will rename (renumber) the .wav filenames with numbers starting where the .flacs leave off.

Bruce S said...

I have to give it to the Settergren boy.The key word is the move command is really a rename command and it gives the .wav files the numbers starting from where the .flac files left off.

Why I am doing this is another question entirely.

Ellen said...

You could try Typepad, although it's not free - though they do have some cheap plans. It's a WYSIWYG version of Movable Type, which is what I used for a long time after my move from Blogger/Blogspot and before my most recent move to WordPress.