(To view this text file, please use Word Wrap)


If you've ever burned a lot of MP3s or other files to CD, you might find that the names get cut off. Here's a handy-dandy script that, on a Windows machine, trims the name to 64 characters, so it'll fit on a CD without problems, then includes a batch file in each directory that expands the name back to full after you put them back onto a hard drive...
 
Very useful, if you're me, or someone like me.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Use:

1.) Drop the script file into the target folder, with files or subdirectories where files need to be renamed.

2.) Right-click and hit "Run With Console".

3.) It renames any long files to xxxxx~#.ext, where xxxxx is the name, ~ is ~, # is a unique number, and ext is the extension (it does everything, not just MP3s). It's directory recursive (it looks into subdirectories, too).

For example:
The Really Long Band - So Long Baby (EP) - (05) So Long Baby (DJ Indecipherabile Hot Hot Mix).mp3
may become:
The Really Long Band - So Long Baby (EP) - (05) So Long B~4.mp3

Which will fit on a Joliet CD, no biggie.

4.) It makes two handy "undo files" for getting the full names back. One, in the root, is called "restore-all.bat". Run this to restore all of the files in all subdirectories. It also makes one in each directory in which it named files, called "restore-me.bat". Run this to only restore the current directory.

5.) You can burn with confidence. Nero might still give ISO errors on the foldernames, but unless you try to open it on MacOS 9 (maybe 10, too), it should be all right. If you're transporting the files from place to place, you can dump them on a hard drive, run the renamer, and everything's back to normal.

There is also a tool called "Delete ALL .bat files (Recursive).vbs", for use after you de-trim the file names. It looks in the current directory, and all subdirectories, for .bat files, and writes a file, "delbat.bat". Review, then run "delbat.bat" to delete all of the .bat files.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Known bugs and limitations:

o=> If you are running Windows 95 or 98, make sure you update to the latest version of Windows Scripting Host. 2000 and XP ship with an adequate version. For simply expanding filenames with "restore-xxx.bat" files, no update to the WSH is necessary.

O=> If you get a deluge of dialog boxes, you probably just double-clicked the script. To run these vbs files, you need to right-click and hit "Open With Command Prompt"

o=> If you have a file with an *extention* longer than 62 characters... I don't know what'll happen. Don't do it.

o=> Make sure none of the files are open or playing when you run the Trim script. It will cause a sharing violation and kill it prematurely. If this happens, run the "expand-all.bat", then "Delete .bat files (Recursive).vbs" (to remove the restorer files, see notes below), drop the files in again, and retry. If you have a file open in Winamp, stopping (not pausing) seems to be all right.

o=> This script will not change directory names, only files.

o=> If the chop-off point happens to fall between digits of a 2-digit track number, the resulting files may be out of order when sorted by filename, or on a portable player.

o=> Running "Delete .bat files (Recursive).vbs" WILL delete ALL files ending in .bat, recursively within the directory. Be warned. This will also kill the batch files used to run the scripts. If you require them, keep a backup outside of the directory.

o=> "Delete .bat files (Recursive).vbs" will temporarily create a file named "delbat.bat"

o=> IMPORTANT! The "Delete .bat files (Recursive).vbs" will mark for deletion ANY file with ".bat" in the name. Be sure to check the "delbat.bat" file (Edit, not run it) before you run it. I'll be fixing this later.

o=> This comes with no warranty for fitness, merchantability, or expectation that it won't fuck anything over. Test first, use at your own risk.

O=> The .vbs files given, and the .bat files created with this script only work on Windows-based computers.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

What's included:

o=> Delete ALL .bat files (Recursive).vbs
This is a good one to have after you de-compress the filenames. It deletes all .bat files
in the current directory and all subdirectories.

o=> trim2.vbs
This does the trimming. It trims all files in the current directory, and all subdirectories, to 64 characters (including the extension, which is included in full)

o=> readme.txt
This file. Duh.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Relatively Uncopyrighted (?)2003 Rudy Fleminger - arcticdoom@pixelsaredead.com