Visual Basic tool for renaming files en masse.

Published on
13,195 Points
2 Endorsements
Last Modified:
Holier than the Pope.
Applications concerned with document scanning and archiving, and other automatic file generation software, can produce large numbers of files with primitive names allocated at runtime. These names can be based on such primitive identifiers as time and date stamp information only, which may not be sufficiently descriptive of the files' contents or general type to be of much use in subsequently identifying their relevance. In such cases, the files may benefit from being renamed categorically. So for example, say we have 1000 files containing photographs of automobile parts, the original names of these files could be changed from those relatively unhelpful datestamps, to names reflective of what they actually contain.

This VB programme relieves the tedium of having to do that job on large numbers of files manually. The user is presented with a template into which any combination of alphanumeric filename characters can be entered. Each character in the filename template can have its dynamics controlled, meaning that there is a choice at individual character level, as to whether to make the new character in a given position fixed, or incrementable.

This allows a bunch of files to retain a kind of root identifier in part of their name, so that they can all be instantly recognised as belonging to the same group, but at the same time other characters in the filenames can be made dynamic, so that they run through the alphabet, or cycle through numbers 0-9. You can even adjust the starting digit or letter in each of those positions to further control subdividing files into discrete sets where they have close associations. And of course there is thereafter no reason why you cannot point the software at those new files (probably in a subfolder of their own by now), and rename them "en masse" again, to an even finer level of description.

The programme was conceived and written many years ago, and long before I became interested in Java. It has some powerful features, but, be warned, it was never developed to the point where it is free of niggles, nor, more importantly, to the point where it has an "undo" button, so its power can be easily abused and present significant dangers to the filesystem if aimed at the wrong directory.

It is therefore highly recommended that you use it only if you are an experienced programmer - VB ideally - and then in the knowledge that it might get you in hot water if you don't hive off a couple of test directories first containing junk files to play with and experiment on. You'd very likely anyway want to check the code for yourself, and improve or adjust it for your purposes.

The clue to how it functions is essentially in the interface itself. There is no documentation, and one really needs to load and run the .exe to see what's going on. That is why it is so important to make some junk files and folders first, that you can simply wreck and replace.

For some reason, known only to myself but forgotten long ago, you move the mouse down to the bottom of the main form to expose three buttons to actually run your renaming template. They are mouseover buttons, so you can't see them without moving the pointer south.

File renaming is challenging, as the permutations of what can be done with the new names is limited to filename length and the combinations that can be made from the combined positions. Therefore if the programme were used for serious-use renamings, then you need to be aware of how many files you are dealing with, and ensure that the template you build, and the alphanumeric cycling mode you choose for it, are sufficient to handle the number of files involved. If you run out of permutations part-way through a renaming session, it can be like looking for a needle in a haystack to see which files have been missed from the process.

The Attached Files.

The source code is contained in the .bas file attachment. This needs little introduction of course, and should hopefully be readable by any text editor or IDE. This applies also to the forms, which are included in the .zip file along with the source again. There is no .exe included of course, and the best way to obtain one will naturally be to import the source files (once unzipped) into a Visual Basic or Visual Studio IDE, and compile from there. The .scc binding file is absent, which as far as I can remember is an association with a project, so in an ideal world, getting the source into an IDE and saving it as a project, would remedy that. I could make the .exe available some how or other I suppose, but I'll take notice of any requests for that if and when they arise.

For anyone wishing to extend, strengthen or smooth-out the code, you are welcome to do so and make any adaptations you wish, without copyright infringement. The notices and splash screen ornaments, in which appear the names of terrifying-sounding organisations, are there for effect and were made at the time as an experiment in jazzing-up the boot-up - none of the corporations are real! However, I am, and if you find any of the material useful or interesting or both, it would be nice to hear about it, and nice to know that you recognise from where it originated.

Depending on the interest shown for the article and code, I will add to the blurb on it if I am able to remember more details, and am available to answer any questions if I can, so get in touch if you have any of those. Thanks, krakatoa.
Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free