|
|
|
2003 TextMaestro Technologies
|
Example 12
|
Since you are dragging a folder, TextMaestro will display Directory Usage dialog. (See Working with directories for details on Directory Usage). Use the setup as shown on the right below:
Note Remote directory for all files (right picture above) cannot be left empty. Add anything in this filed. Hit OK. Below is the view after all the .html files are added.
Now we are ready to go. Renaming these files could be done in three ways as stated earlier: (a) Using TextMaestro GUI. (b) Using TextMaestro GUI with advanced features. (c) Using a script file from a command window. Method (a) is the simplest. We expect, this would be the default method of everyday file renaming tasks. However, when you need more power you can resort to method (b). Method (c), as powerful as method (b), is aimed for console driven environment, since it uses script file and has no dependency on TextMaestro GUI.
(a) Using TextMaestro GUI to rename files: Top Suppose you have the files listed on TextMaestro as shown above. Now, from pull-down menu select: Files | Work on files | Multiple... | Rename/Duplicate multiple files (Ctrl+Shift+R). Alternatively, right click on the selection and select: Multiple... | Rename/Duplicate multiple files (Ctrl+Shift+R).
Then the following dialog will appear. The navigation and controls on this dialog are quite intuitive and it is likely that you will go on to make some experiments here. Before you do, we would like you to notice that 3. Using user specified extension is what you want here to rename all .html files to .htm extensions. Go ahead and select scheme 3. Enter .htm in place of extension.
If you are satisfied with these names, click on Rename files to above new names button. And this will rename all the files on the main list using these names above.
After the renaming is over, expect to see this view which denotes that all the files now have .htm extensions.
(b) Using TextMaestro GUI to rename files for advanced cases. Top Note the last scheme on Rename/Duplicate
Selected Files dialog, in particular,
Here is an example. Suppose new names should appear like this:
I.e., first letter of each name will be in upper case and the extension be .htm. Hit Ctrl+R
to open Report
dialog. Accept the following specifications and hit on the Report
This will dump the report on the Input window. Using the text on Input window we will generate the desired list of destination filenames onto Output window. This time we will use a different definition in the Work Pad as shown below.
In a nutshell, each line of the Output window is nothing beside the desired filename for each corresponding item in the list, where first letter is in upper case (due to the case qualifier 'p' after *1) and .html is replaced by .htm.
Each line is destination filename generated in Output window. An entry in Output window may contain file-path in addition to the filename. In that case the new file will be at the location dictated by the explicit file-path.
Now hit Ctrl+Shift+R, and Rename/Duplicate Selected Files dialog will appear. If you select scheme 5. Using names from Output window here, and click on View results button, you will see the following:
In summary, TextMaestro grabs the text found in Output window, and assigns its n-th line to the n-th file item. Caution: It is your responsibility to make sure that the assigned line denotes a valid path and filename. TextMaestro will create the destination directory if it does not exist, but will not perform any sanity check on the validation of a name.
Hit Rename files to above new names button. The process may take a few moments based on the number of files. After the renaming is over, expect to see this view, which denotes that first letter of each name is in upper case and the extension is .htm.
(c) Using a script file from a command window to rename files. Top Suppose you have the files listed on TextMaestro as discussed in (0) Preparation before renaming files step. (This picture was shown earlier).
We want to rename these files using a script. This method can take place on any console driven environment such as UNIX, VMS, Windows, etc. However you have to follow the command and scripting language of the environment. In contrast, GUI method works only on Windows. Also note that writing script files is never a unique method. You can accomplish the same task using various types of scripts. What we presented below is just an example for Windows. By no means it is the best solution. Let us write a script file. We will use Report feature and one of the text conversion methods to accomplish it.
Select all items (Ctrl+A) in the list. Then hit Ctrl+R to open Report dialog. (This can also be accessed
through Session toolbar). Set
Fields and Gutter as shown below.
Note we opted for Local
directory and File
name. Hit the Report
This will list all the selected files preceded by their local paths in the Input window. See below (partial view):
Now using this text on Input window, we will create the script file on the Output window using text conversion. Here is the settings of the conversion.
Here is the macro definition and the Output window:
The rules behind the Macro definition are explained here in details. It is worth while to review these rules. In a nutshell, each line in Input window has two tokens - first token is an absolute path, the second is a file name. <*1> stands for absolute path and <*2> for filename. So the command is: cd <absolute path> rename <file-name> <file-name where .html is replaced by .htm> Hit the Convert
Just paste the copied text on the cmd window as shown below. That will rename each .html file in the list.
Please keep in mind that the Output window text may contain a large number of lines, based on the number of files in the list. It is a good practice to try two or three pairs of commands and see if the script is right or not. Then you can dump the whole text on the console.
Now that the files are renamed, the main list box will display them as missing as shown below.
|