<

Visual Basic tool for renaming files en masse.

Published on
12,905 Points
3,205 Views
2 Endorsements
Last Modified:
Awarded
krakatoa
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.
renaming.bas
ren2ZIP.zip
2
Comment
Author:krakatoa
  • 2
  • 2
4 Comments
LVL 17

Author Comment

by:krakatoa
Hi and thanks ericpete;

I could not discover where and how to use your suggestion to set the article to Editor Review,sorry, so I hope my resubmission is ok. Of course if I need to do something explicit about this, you'd let me know I assume.

As to the body of the article, I have brought in a paragraph about the files. I think the most important thing to say was that the .exe and the .scc files are not there, and I am pretty sure that even a beginner VB programmer will be able to easily handle what to do with the source and get it compiled easily.

If there is anything else that needs attention, pls say.
0
 

Administrative Comment

by:Eric AKA Netminder
krakatoa,

Congratulations! Your article has been published.

ericpete
Page Editor
0
LVL 17

Author Comment

by:krakatoa
ericpete - that's fine and great, and thanks for the files prompt - I agree entirely with what you said. ;)
0
 

Administrative Comment

by:Eric AKA Netminder
krakatoa,

Your article has been designated EE-Approved. Very nicely done!

ericpete
Page Editor
0

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Join & Write a Comment

Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month