Sunday, January 19, 2014

Bulk File Renaming

While in the process of transferring music and shows to a media server, I noticed an annoying problem. All the file names were formatted differently than I wanted. After manually changing files in one folder and realizing how long it took, I thought there must be an easier way. After a very short Google search, I figured what a better way to support what I need than to make such a program myself. So I created rename.py. It is a command line utility that allows bulk renaming of files and/or directories, supporting basic stripping, regular expression matching and Python string formatting.

You can find the download link for it here.

Now here is a quick rundown on ways to use it.

#strips first 4 chars off every file
./rename.py 4
#strips in the Music/5FDP folder
./rename.py -p Music/5FDP 4
# Takes any file in Music/RATM that looks like "something - somethingelse"
# and changes it to RATM.somethingelse
./rename.py -p Music/RATM -r ".+ - (.*)" "RATM.{0}"
# help for more info
./rename.py -h

There are other options like -d for including directories and -o for only directories. Named groupings are also supported, for more information, it would be best to look into regular expressions and Python's str.format() to fully utilize this tool.

Tag Cloud

.NET (1) A+ (2) addon (2) Android (2) anonymous functions (1) application (5) arduino (1) artificial intelligence (1) bash (2) camera (1) certifications (3) comptia (4) css (1) customize (8) encryption (1) error (11) exploit (4) ftp (1) funny (2) gadget (3) games (2) GUI (2) hardware (7) haskell (6) help (2) HTML (1) irc (1) java (2) javascript (11) Linux (13) Mac (3) malware (1) math (4) network (5) perl (2) php (3) plugin (2) programming (13) python (9) radio (1) regex (2) security (12) sound (1) speakers (1) ssh (1) story (1) Techs from the Crypt (2) telnet (1) tools (7) troubleshooting (3) Ubuntu (3) Unix (1) virtualization (1) web design (4) Windows (6) wx (1)