© Matti Mattila, CPFA, CISA, CIA

11. File Renaming Macro, 3rd version (NAM3)

Previous Item Previous menu
What the macro does?
The macro is an improved version of the macro described on the previous page. The macro creates (1) a bat file both for renaming files in a selected folder (identified by a file selected by the user) and (2) a bat file for reversing the renaming. The macro renames only files with file extention (e.g. .jpg). The macro is made for Windows Xp and IDEA 8.
Background
For various reasons you might want to rename files based on the alphabetical order of their existing names in stead of age of files. Still, you might want to keep the latter mentioned option available.
Operating system has the best information about ages of files. The simplest way to create a file where file names of interest are in alphabetical order is DOS functionality, e.g. command combination 'dir *.*|sort/+37>zz.txt' in Windows XP [1]. Such a file contains names of all files in a folder.
Running the macro
Before running the macro, please read ReadMe file.
The macro works as follows:
- Soon after starting the macro you are shown the dialog in picture 1.
Picture 1
Picture 2
By default the macro renames files based on the alphabetical order of the existing file names. If you, however, want the files to be renamed based on their age select "According to age of files".
To continue the run click 'Select any file to be renamed': the browser starts. Select ANY file to be renamed. By selecting a file, you actually select the folder, files of which are to be renamed.
To stop the macro, click the button bearing text 'End Script'.
- Next, you are asked to submit prefix for the files to be renamed (File name prefix:'). In picture 2 the new file names will start with 'Helsinki_10Jul_'.
The prefix is followed by a running number; submit it, too. Here the first running number will be '1'.
To continue execution of the macro click 'OK'. To stop the run click 'Cancel'.
Soon you will be informed where there is a bat file for renaming the files in selected folder (picture 3: [2]).
Running a bat file
To run 'zz.bat' click it in the folder where it is, and the files within the folder will be renamed. You can edit the bat file e.g. with Notepad. You can reverse the renaming by clicking 'rev.bat' in the same folder, where 'zz.bat' is: the old names of the files will be restored.
Demo version and full version
To download the DEMO macro click here. The zip file contains five files, including batch and mask file for Windows XP (XP.zip) users. To buy a full version of the macro, click here.

[1] The number '37' indicates the column position where the file names start in 'zz.txt'.
Picture 3
[2] Message from the macro in the picture to the left.
See also functionality of 'ReNam' Excel macro in renaming files!