Archive for Random Things

Cover Copier

Here’s a little script I created to copy all of the covers from my mp3 folders over to my flac folders. It also came in handy a few days ago when I accidentally deleted all of the covers that were present on my Sansa.

#! /usr/bin/env python
 
import os
import sys
import shutil
import string
 
for root, dir, files in os.walk(sys.argv[1]):
    if len(dir) == 0:
        copy_from = sys.argv[2] + '/' + root.replace(sys.argv[1],'').translate(
                string.maketrans(':<>\|*?','_______'))
        try:
            for file in os.listdir(copy_from):
                if file == '.directory' or file.endswith(('.jpg','.jpeg','.png','.gif','.bmp')):
                    copy_file = copy_from + '/' + file
                    shutil.copy(copy_file, root)
        except OSError: pass

Comments

FAT sanitizer

Have you ever had to move a lot of files from a sane filesystem to one that behaves more like FAT? Do these files have “strange” characters in their names, such as ‘:’, ‘?’, or ‘*’? This simple utility can rename these files so that the FAT-invalid characters are replaced with ‘_’. Works great for “fixing” the filenames on your music collection before transferring it to your portable audio player. You can download it here.

#!/usr/bin/env ruby
 
require 'find'
 
bad_str = ":<>\\|*?\""
bad_files = Array.new
 
Find.find(ARGV[0]) do |file|
	bad_files.push file
end
 
# reverse array so bad directories come after the files
bad_files.reverse!
 
bad_files.each do |file|
	basename = File.basename(file)
	if basename.count(bad_str) > 0
		dirname = File.dirname(file)
		new_file = File.join(dirname, basename.tr(bad_str, '_'))
		puts [file, ' -> ', new_file].join
		File.rename( file, new_file )
	end
end

Comments

Pumpkin Carving

Sparked by a trip to SuperFresh to get some biscuits for dinner, I came across some huge pumpkins for $3. Thus, I was inspired to create a nerdy pumpkin for Halloween. I did all the carving with my Dremel rotary tool and a dinner knife. To keep it from rotting, I covered it in WD-40.
Read the rest of this entry »

Comments (1)

lolcat iz pleezd

iizbukket.jpgiizninja.jpg

Comments (1)

« Previous entries