The Experimentor

Experimenting ON Earth

Renaming files downloaded from the web automatically for better readability using Python

Today I downloaded an mp3 with url:

http://music.music.com.bd/Music/S/Sumon%20&%20Anila/Ekhon%20Ami/02%20-%20Sumon%20&%20Anila%20-%20Ekhon%20Ami%20[music.com.bd].mp3

So the downloaded file (downloaded with Multiget) has the name:

02%20-%20Sumon%20&%20Anila%20-%20Ekhon%20Ami%20[music.com.bd].mp3

But it’s awesome so I renamed it to:

02 – Sumon & Anila – Ekhon Ami [music.com.bd].mp3

Which looks much prettier. But as I continued to download more mp3s it felt
labourus to rename every single file that I download. So I thought about some
automation script. Batch file (Windows) / Shell script (Linux) would be good
enough but that would require me to manipulate the name string directly to replace
the %20s with spaces. Not a big deal but the name could contain things other
than %20s (spaces) . So a better solution, I thought, would be Python’s url decoder.
Here is a snapshot of the code from my favourite editor IDLE and also a download link to the python source file.
Place the python script in the folder containing your files and double click on the
script to see it at work!


Here is the download link simply_rename.zip

February 24, 2008 - Posted by asadujjaman | ENTERTAINMENT, Python | | 2 Comments

2 Comments »

  1. i am gonna show this to my friend, bro

    Comment by Tobiaszv | March 24, 2008 | Reply

  2. Tobiaszv, bro, let me know what your friend says.

    Comment by asadujjaman | March 25, 2008 | Reply


Leave a comment