Archive for Programming

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

A wild project appears!

Lately I’ve been working on a new project to sync music with my Sansa e260. Unsatisfied with manually moving files on and off of the tiny flash drive, I began work on an application to manage playlists and sync them for me. I’ve gotten it to the point where it scans my music collection, allows me to create playlists, and syncs those playlists with any directory I specify. In the future, I plan on implementing removable device recognition and cover attachment and resizing. It also currently only functions as a command-line client, but there are plans to develop a GUI frontend for it once the base library is stable enough.

Anyway, the project page is available behind the link on the right (or right here).

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

Officially Official

Mokash is now an official OpenMoko.org project. I’ve just finished copying the current svn repository over to the openmoko.org repository, and that will be the new official repository. The old repository on my home server will occasionally be updated to match the openmoko.org one, but it probably won’t be very often, so don’t come here looking for it. I still need to move the current tickets and such over to the OMO tracker, but that’s not a high priority. Thanks to this, this project will have higher availability (no more monthly reboots or crashes!) and the opportunity to be seen by a larger amount of OpenMoko users.

Comments (1)

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »