I like to have my music, movie, and picture files named a certain way. When I download files from the internet, they usually don’t follow my naming convention. I found myself manually renaming each file to fit my style. This got old realy fast, so I decided to write a program to do it for me.
This program can convert the filename to all lowercase, replace strings in the filename with whatever you want, and trim any number of characters from the front or back of the filename. Here is the usage output:
usage: rename.py [options] file1 ... fileN
-h, --help show this help message and exit
-v, --verbose Use verbose output
-l, --lowercase Convert the filename to lowercase
Trims NUM of characters from the front of the filename
Trims NUM of characters from the back of the filename
-rOLDVAL NEWVAL, --replace=OLDVAL NEWVAL
Replaces OLDVAL with NEWVAL in the filename
Here is a few examples of what this program can do.
]$ ls -l
-rw-r--r-- 1 matt matt 0 Mar 4 14:03 01-BandName_-_SongName-group.mp3
-rw-r--r-- 1 matt matt 0 Mar 4 14:03 02-BandName_-_SongName2-group.mp3
-rw-r--r-- 1 matt matt 0 Mar 4 14:03 03-BandName_-_SongName3-group.mp3
]$ rename.py -f3 -r "_-_" "-" -r "-group" "" *.mp3
]$ ls -l
-rw-r--r-- 1 matt matt 0 Mar 4 14:03 BandName-SongName.mp3
-rw-r--r-- 1 matt matt 0 Mar 4 14:03 BandName-SongName2.mp3
-rw-r--r-- 1 matt matt 0 Mar 4 14:03 BandName-SongName3.mp3
]$ rename.py --replace="Band" "" -lv *.mp3
BandName-SongName.mp3 -> name-songname.mp3
BandName-SongName2.mp3 -> name-songname2.mp3
BandName-SongName3.mp3 -> name-songname3.mp3
]$ ls -l
-rw-r--r-- 1 matt matt 0 Mar 4 14:03 name-songname.mp3
-rw-r--r-- 1 matt matt 0 Mar 4 14:03 name-songname2.mp3
-rw-r--r-- 1 matt matt 0 Mar 4 14:03 name-songname3.mp3
Well I decided to dual boot my new Core2Duo MacBook Pro with Linux and OSX. For the most part I followed the excellent OnMac.net wiki article, however I did add a few extra steps as well as run into a few problems.
Read more »
Well I was able to get all my posts though Googles cache, however I was unable to get the files linked in the posts. I have decided to remove all links to the missing files until I am able to get them back. I will be going though old archives of mine to try and find some of these files so I can get them linked again.
I have also installed a plugin so you can view my pictures. You can browse my albums by visiting: Matt Weber’s Photo Gallery.
So it looks like I will be unable to get the contents of my old site back, so I will most likely get what I can from Google’s cache and forget about the rest. Sorry.
I have started reading up on css, xhtml, and ajax so I can throw together a new design. I think the default WordPress theme is good enough until I can get a new one ready. Any suggestions for the design would be great.
My old host took MattWeber.Org offline this week for an unknown reason. The site was being hosted for free, so I can’t really complain. Anyways, MattWeber.Org is now being hosted by QualityHostOnline and using WordPress instead of PyBlosxom.
Being taken offline isn’t that bad because it motivated me to do something with my site. With that in mind, I am going to redesign the layout, post more often, and keep everything up to date.
For those of you looking for an old post, I can hopefully get those back and have then re-posted sometime soon. Thanks.
I needed a quick refresher on my C++ and XML skills, so I decided to throw this little program together. Basically, this program will let you create and modify an XML file which keeps info on your books. It stores the Title, Author, and ISBN on any book you add. This program uses TinyXML to work with the XML file. This program is only good for a tutorial on TinyXML and C++.
Compile with this command:
]$ g++ -o xmltest xmltest.cpp book.cpp tinyxml.cpp tinyxmlerror.cpp tinyxmlparser.cpp tinystr.cpp
Here are the links to the files I programmed:
Here is a link to the entire project:
Here is a project I wrote last semester for a client/server systems class. Basically the professor assigned us a table from the Northwind Database. Our first assignment was to take that table, export it to a text file, then create a program to parse that text file and create a random access binary file. We were then to create a GUI that will read, write, and modify records from that binary file. I decided to write my project assignments in Python since that is my programming language of choice.
We spent half the semester working on this part of the project instead of learning anything related to client/server systems. Creating the GUI was extremely easy using Qt3 Designer and pyuic, so most of my work went into the reading and writing of the binary file.
Finally about 3/4 of the way though the semester we were assigned to modify our program to read, write, and modify the binary file over the network. The server contained the binary file, and the client connected to the server to get information from the binary file. This part of the program was actually fun to implement.
Our very last assignment was to merge our client and server with another students. I partnered with Eric Gaumer since he was also working in python. The following code is the result of our work. We took my GUI added the features his client needed and then added his server code to mine.
Simply start the server, then when you start the client enter the ip address where the server is located.
Note: PyQT and PyKDE are required to run this code.
Here is a homework question from my Problem Solving Strategies class, along with my answer written as a python generator.
Design and code a decrease and conquer algorithm for generating all permutations of N elements in an array. Use the decrease-by-one method given in class where the parameters are: a prefix string, the number of elements whose permutations are to be concatenated with the prefix string, and the set of those elements. Turn in the code and the results for running it with a 4 element set containing A, B, C, and D.
def AllPermutations(elements, numElem=None, prefix=):
if not numElem: numElem = len(elements)
if numElem == 0:
for index in xrange(numElem):
newPrefix = prefix[:]
newElements = elements[:index] + elements[index+1:]
for perms in AllPermutations(newElements, numElem - 1, newPrefix):
if __name__ == Ã¢â‚¬Ëœ__main__Ã¢â‚¬Ëœ:
for perm in AllPermutations(list(Ã¢â‚¬â„¢ABCDÃ¢â‚¬Ëœ)):