Jump to content

script for renaming files

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
aloishis89

aloishis89

    Newbie

  • Members
  • PipPip
  • 12 posts
I convert my music with a program that for some reason decided to add some random junk to the end of the file name when it spits it out. The format for every single file name is like this: Name Of Song (dc9351243).mp3

I want to write a script that will go through a directory of music files and systematically rename every file without the last 12 characters, so in my example, it would just be Name Of Song.mp3. I figure there is a simple way to do this. I know MATLAB, some batch, and am learning C. I might be able to write a script in MATLAB to do it, but I would optimally want a batch script that I could place in the correct directory and execute, renaming all the files. Like I said, I am only slightly familiar with batch programming, can anyone give me a script to do this, or at least point me in the right direction? Thanks.

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
You can do this using batch. You would need to take a substr (substring) of the string for the entire length - 12. I don't know the batch commands to do this but in PHP it would look like this:

$filename = substr($file,0,strlen($file)-12);


#3
aloishis89

aloishis89

    Newbie

  • Members
  • PipPip
  • 12 posts
Ha, well it turns out that as I was reading my RSS feeds, I came across this.
Its a program called D-FileMU (odd name) that does exactly what I need and more. There is a good write up on it at makeuseof.com. If I have time, I would still like to try to write my own, but for the time being, I'll just use this. Thanks for the help though.