Tutorial 02: Powerful file renaming
October 31st, 2006How many times have you found yourself manually renaming a sequence of files? Annoying, isn’t it? Most of the times, sequence renaming follows a pattern that can be easily automated. This tutorial shows how file renaming shines in Fileaze.
Note: this tutorial presumes that you followed the previous one and are able to perform the operations explained there.
Let’s get back to where Tutorial 01 left us and suppose we have a C:\all-photos\2006\10 folder containing a bunch of JPEG files:

We could want to change all these filenames to carry the words LondonTrip to make it easier to recognize them when looking at the files in Windows’ explorer. At the same time we don’t want to keep the IMG part since it doesn’t give us any information but we want to retain the image number and underscore. What we want to end up with is files named like this LondonTrip_4468.JPG.
Let’s create a new job and name it “Photo rename”, then move to the Sources tab and add C:\all-photos\2006\10 as Folder source. We don’t need to include subfolders or keep the folder structure. Since our folder only contains JPEG files there’s no need to specify a file filter. Our source definition will then be:

We can click Save to get back to the job editor, switch to the Actions tab and add a new Rename action:

Now on to the tricky part. We must think about the filename structure and how we want to preserve or replace parts of it. Our files are all similar to
IMG_4468.JPG
Let’s split this up. We have a fixed first part, IMG_, that we want to change into something else. Then we have a variable part, the photo number 4468 (and 4469, 4470 and so on) we want to keep. Then the dot and the extension we want to keep as well. Our files are then in the form
IMG_*.*
where the first star represents the number and the second one the extension.
What we want to achieve is changing these files into something like
LondonTrip_4468.JPG
or if we substitute the parts we want to keep, in general we want this result:
LondonTrip_*.*
where the two stars correspond to the matching segments of the original filename.
This is straightforward in Fileaze and only needs the Rename action to be defined properly. Please note that since *.* is treated in a special way to always match all files (even if you put something before it), you have to put a star at the beginning to make it work this way. This disables the special treatment even if *.* is still present in the pattern. To sum up, the Rename action must be defined like this:

Remember that to input the Folder and file filter definition you need to enter the filter dialog pressing the dotted button on the right.
We’re done. Let’s click Save to get back to the job editor and run the job. If everything was set up correctly this will be the job progress

and all the files will be renamed as expected:

Improving the rename job
Parameterized renaming
Remember from Tutorial 01 that Fileaze supports custom constants inside jobs. In this case creating a constant is useful to have different captions than LondonTrip for subsequent runs and avoid editing the job every time. Just change the action substituting LondonTrip with a constant definition like %const_caption%

and at every run Fileaze will ask you for the caption variable to be used as the first part of the target filename:

Renaming as part of the download job
Having two jobs for photo download and rename could be not always the best solution. What about incorporating the rename action inside the download job we created in Tutorial 01?
This can easily be done but requires a short explanation about how the copy action works in Fileaze. In the previous tutorial, we copied the files from the memory card, we didn’t move them. When you copy files in Fileaze, the original files are kept in the pool of sources that are affected by the subsequent actions and the new copies are added too. This means that if we simply add a Rename action to the download job, Fileaze will try to rename all files, including those on the memory card! To avoid this, in the rename action we need to select only the copied files on disk C: and avoid the action affect files on the memory card.
For this reason what we’ll do is create the rename action like above but adding C: to the filter pattern, like this:

Fileaze will only rename files that match so the original files on H: won’t be touched!
The Actions tab will now look like this:

Running the job will require the two constants to be filled in

and the job will yield the expected result:





