Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need a way that I can automatically scan my whole drive and rename my *.mp3 to *.3pm or delete them. How I could do that?

share|improve this question
any particular platform? – quack quixote Apr 19 '10 at 11:08
Windows-commandline is better (as i can schedule it) – Magnetic_dud Apr 19 '10 at 22:44
up vote 1 down vote accepted

For the renaming part, you could do this with Ant Renamer. (Although it's hardly the best way to do that)

When you click "Add folders", you should check all options (add selected files, add selected folders, apply these two options also to subfolders), and select your drive. It will take long to make the initial list, as it will retrieve the total list of files to rename.

Once the files are listed, you can set a "string replacement" action, from .mp3 to .3pm.

You can't delete them from this program, though.

That said, there is probably a better way to do this, because this method will cost a lot of time for nothing, with listing and attempting to make an action on the totality of files from the drive, not only mp3s.

share|improve this answer
I will try and see how fast will be to scan my whole drive – Magnetic_dud Apr 26 '10 at 15:57

Given a Cygwin or MinGW environment, or even GnuWin32's find:

# delete them all
find /cygdrive/x -iname '*.mp3' -delete

# rename them all
# requires the classic Perl rename script or workalike
find /cygdrive/x -iname '*.mp3' -print0 | xargs -0 's/\.mp3$/.3pm/'

This is the classic Perl rename script; it's available in many various places. Here's a more updated version on Perlmonks. Download it and save it somewhere on your PATH with the name (or update the command with the name you did give it).

Replace x with your drive letter (for Cygwin) or the corresponding path for your drive's root in MinGW or GnuWin32.

share|improve this answer

Are you familiar with Python? You could try using the os module:os.rename(old, new)

and select all of the files *.mp3 using the os.glob module.

share|improve this answer
That would be an answer on Stack Overflow, rather. – Gnoupi Apr 19 '10 at 13:25
I thought about that as I wrote the answer. So is no code allowed in responses? – celenius Apr 19 '10 at 13:27
it's not forbidden. I'm only saying that here, solutions without programming are more suited, simply. – Gnoupi Apr 19 '10 at 13:29
a simple example script makes a better answer here, as opposed to listing the python modules to use. – quack quixote Apr 20 '10 at 9:30

I need a way that i can automatically scan my whole drive and rename my *.mp3 to *.3pm or delete them, how I could do that?

Well, you say it can rename them or delete them, so here is a command that will delete all *.mp3 files.

del *.mp3 /S /F /Q
share|improve this answer
rename is better, because i don't 100% trust a script :-P – Magnetic_dud Apr 21 '10 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .