simple script needed for file renaming
ihave a list of files that i need to run script on. i need a simple script (preferably .bat or any other) to help me accomplish two things:
1, run a script over the folder that is containing these files to re-name these files 2, as some are audio files, i need a script to also re-name these file's 'Title' |
Quote:
You don't really describe two separate things---please tell us the criteria to be used for renaming all the files.....or give some before/after examples. The general form would be: Code:
for file in `ls <dirname>` do |
If you are using Debian or a Debian-based distro, you have a program already installed name rename that can do wonders. Check man rename. (There's a program with the same name on other distros, but it doesn't seem nearly as powerful.) There are also lots and lots of programs, both gui and command-line, that can do renaming. Two I can think of quickly are GPRename (a gui, Perl-based renamer) and mmv (a command line renamer).
In my experience, renaming is one of those things that feels like it should be very easy, but there are lots of subtle gotchas. (For example, do your song titles have lots of spaces in their names?) So, even for a "simple" job, it's often better to get a utility that's robust and fully tested. Beyond that, it's hard to give concrete advice without more details about what the files look like now and what you want them to look like. For something like this, some sample data (both before and after) would help a lot. |
specifically (in this path 'C:\Documents and Settings\johny\My Documents\My Music') i have audio files in this order:
1, 112file01.mp3 2, 112file02.mp3 3, 112file03.mp3 4, 112file04.mp3 5, 112file05.mp3 etc, and wants to convert them to: 1, 00112_file 001.mp3 2, 00112_file 002.mp3 3, 00112_file 003.mp3 4, 00112_file 004.mp3 5, 00112_file 005.mp3 etc reason is that i want them to remain sequentialy organized when moved into iTunes - for iPod. otherwise it mix up in the entire iTune. Any sample script to do this please? in the real sense i intend to do this in xp machine, so if DOS solution is available it will be much appreciated. if not, i also have linux (CentOS) box. |
Quote:
example usage: Code:
# ./script.py -D "/path/to/files" -p "file" -e "_file" -l "*.mp3" # -l options lists files only Otherwise, you can just write a simple script using shell tools such as sed, rename, or even bash. |
thanks so much GhostDog, but i have two more questions to ask:
1, As these .mp3 files inside each folder are just too many (i listed just 5 above though - but its just many), in all i have over 100 folders. Is there a way to write this script without specifically describing each .mp3 file name. in other words to write the script in a way that it can loop from one .mp3 file to another inside a particular folder? 2, In addition to re-naming the files name, i also want to re-name these files 'Titles', so how will the script to do this look like? |
Here's a pseudocode for the shell
Code:
|
His script does that if you read carefully. He says that if you remove the -l flag, it'll actually do the rename, instead of just showing you what it would have done.
|
thanks for all the above, 'will go over it then
|
All times are GMT -5. The time now is 04:02 AM. |