ZTree.com  | ZEN  | About...  

 Index   Back

Rename Mask Rules - Revision 1   [General]

By: John Gruener     Orlando, Florida  
Date: Nov 10,1999 at 03:45

Rules Revision 1:

As you can see from version 1.46y, Kim has worked hard on Rename, and many great features have been added.

I post these rules here so everyone has a complete description of how Rename is designed to work. A number of the rules have changed during the development of the new Rename Mask, so this is a complete, detailed revision, with examples.

There were originally 12 rules, now there are 18. The reasons for this are:

1. The previous rules 11 and 12 have been broken down into five separate rules. This was done to better focus the examples on a particular feature.

2. The date and time elements were added.

3. Template characters and wildcards are now permitted inside the colons.

4. The colon and insertion pairs can now be nested.

One revision which did not affect the number of rules is that the sequential number does NOT wrap if it exceeds the number of digits specified, but instead it adds another digit to the name.

Many of the examples given are not very useful, but they serve to illustrate the logic to be followed, and are good test cases. Some of these examples get a bit complex, so please ask questions if it's not clear. Also, if any errors are discovered in the examples, please let me know.

(NOTE: Version 1.46y does not yet permit periods inside the colons, although they are shown as being permitted in these rules.)

- John

Rename Mask Objectives:

1. Provide consistent and predictable renaming within ZTree.
2. Adhere when possible to the basic use of wildcards in DOS and Windows.
3. Provide for substitution, retention, insertion, and deletion of file name characters.
4. Provide for adding sequential numbers to tagged files, in the displayed order.
5. Provide for adding date and time elements to tagged files.

To accomplish these objectives, the following use of characters are implemented in the rename mask:

1. Non-wildcard characters are substituted for the character in that position.
2. Asterisks represent groups of a variable number of characters to be retained.
3. Question marks represent specific character positions to be retained.
4. Forward slashes represent specific character positions to be deleted.
5. Less-than and greater-than signs enclose characters to be inserted.
6. Colons enclose digits to be inserted as sequential numbers, and date/time elements.

Rename Mask Rules and Examples:

1. The rename mask is separated into two name and extension "sections", separated by the rightmost period. A rename mask is always evaluated against the name and extension sections separately. Additional periods are treated the same as any other normal character.

Examples:

All the examples shown in these rules rename the file "ABC.DEF.XYZ", which is treated as having a 7 character name section and a 3 character extension section. (The mask examples always use numbers for greater clarity).

2. Non-wildcard characters are considered substitution characters, and therefore overwrite that position in that section of the name.

Examples:

"1*.*" = "1BC.DEF.XYZ"
"1*.2*" = "1BC.DEF.2YZ"
"1*." = "1BC.DEF"
"1*" = "1BC.DEF"

3. A leading, trailing or embedded asterisk represents whatever number of previously existing characters remain, and are to be retained, in that position of that section of the name.

Examples:

"12*.*" = "12C.DEF.XYZ"
"*12.*" = "ABC.D12.XYZ"
"1*2.*3" = "1BC.DE2.XY3"
"1.*.2*3" = "1.C.DEF.2Y3"

4. Only one asterisk may be specified in each section.

Examples:

"*123*.*" = Error: Invalid mask
"*.*.123" = Error: Invalid mask
"1*.23*.*" = Error: Invalid mask

5. A question mark represents a character position which is to be retained in that position of that section of the name.

Examples:

"12345??.6??" = "12345EF.6YZ"
"??12345.?67" = "AB12345.X67"
"12??345.6?7" = "12C.345.6Y7"
"?1*2?.*" = "A1C.D2F.XYZ"
"?1*2???.*" = "A1C2DEF.XYZ"
"??1*2??.*" = "AB1.2EF.XYZ"

6. A forward slash represents a character position which is to be deleted in that position of that section of the name.

Examples:

"/*.*" = "BC.DEF.XYZ"
"*/.?/*" = "ABC.DE.XZ"
"??//*./*" = "ABDEF.YZ"
"1?///??.?/?" = "1BEF.XZ"

7. Excess substitution characters are inserted to the right in that section of the name.

Examples:

"1234??5678.*" = "1234DE5678.XYZ"
"1234/?/5678.?987*" = "1234E5678.X987"

8. When no asterisk is present, insufficient substitution characters cause deletion of characters to the right in that section of the name.

Examples:

"123?.?" = "123..X"
"??123.?4" = "AB123.X4"
"12??34.5?" = "12C.34.5Y"

9. Excess wildcards are ignored.

Examples:

"12345678*.*9" = "12345678.XY9"
"*12345678.9*8" = "12345678.9Y8"
"1234*5678.9*87" = "12345678.987"

"1234????????.7?????*" = "1234DEF.7YZ"
"?????????123.?????4*" = ABC.DEF123.XYZ4"
"12????????34.5????6*" = "12C.DEF34.5YZ6"
"??123????456??.*" = "AB123EF456.XYZ

"1234////////.*" = "1234.XYZ"
"////////1234.*" = "1234.XYZ"
"////1234////.*" = "1234.XYZ"
"1??2//????3.*" = "1BC2F3.XYZ"

10. If an asterisk is present with either excess question marks or forward slashes in a section of the rename mask, question marks and forward slashes take priority over the asterisk.

Examples:

"12???3456*.*" = "12C.D3456.XYZ"
"*12???3456.*" = "12C.D3456.XYZ"
"12???3*456.*" = "12C.D3456.XYZ"
"?1*2?????.*" = "A12.DEF.XYZ"
"?123*456?.*" = "A123456.XYZ"
"?12*34???.*" = "A1234EF.XYZ"
"?1234*5678?.9*876" = "A12345678.9876"

"12///3456*.*" = "123456.XYZ"
"*12///3456.*" = "123456.XYZ"
"//123*456/.*" = "123456.XYZ"

11. A pair of less-than and greater-than signs enclose characters which are to be inserted in that position of that section of the name.

Examples:

"<12>*.<34>*" = "12ABC.DEF.34XYZ"
"<12>*" = "12ABC.DEF"
"*.<12>" = "ABC.DEF.12
"*<12>.*<34>" = "ABC.DEF12.XYZ34"
"<12>??.<34>?" = "12AB.34X"
"??<12>.??<34>" = "AB12.XY34"
"?<12>?.?<3>?" = "A12B.X3Y
"*<12>??.*<3>?" = "ABC.D12EF.XY3Z"
"??<12>*.?<3>*" = "AB12C.DEF.X3YZ
"*<12.*" = Error: Invalid mask

12. Wildcards may be placed inside the insertion pair.

Examples:

"<12*34>.<5?6*>" = "12ABC.DEF34.5X6YZ"
"<*12>.<*3>" = "ABC.DEF12.XYZ3
".<4?5>" = "A1BC2.D3EF.4X5"
"*." = "A12C34.5EF.X6Z"

13. If an inserted period is the rightmost period it creates a new extension section. (Part or all of the old extension may become part of the name section).

Examples:

"*.*<.123>" = "ABC.DEF.XYZ.123
"1*.*<.234>" = "1BC.DEF.XYZ.234"
"*.*<1.2>" = "ABC.DEF.XYZ1.2"
"*.<1.2>*" = "ABC.DEF.1.2XYZ"
"*.??<1.2>*" = "ABC.DEF.XY1.2Z
"*12?.?<.34>*" = "ABC.12F.X.34YZ"

14. A pair of colons may enclose sequential digits which are to be inserted in that position of that section of the name. The first file renamed will receive the specified digits, and each file thereafter will be incremented by one. If the number of files to be renamed exceeds the capacity of the number of digits specified, the number of digits inserted will be increased.

Examples:

"*:001:.*" = "ABC.DEF001.XYZ"
":001:*.*" = "001ABC.DEF.XYZ"
"*:001:*" = "ABC.DEF001.XYZ"
"*.:001:" = "ABC.DEF.001"
"*.*:001:" = "ABC.DEF.XYZ001"
"*<.>:001:.*" = "ABC.DEF.001.XYZ"
"*.*<.>:001:" = "ABC.DEF.XYZ.001"

15. The colon pair may contain any valid non-alphabetic characters to be inserted as template characters.

Examples:

"*:-001:.*" = "ABC.DEF-001.XYZ"
"*:[001]:.*" = "ABC.DEF[001].XYZ"
"*:.001:.*" = "ABC.DEF.001.XYZ"
"*.*:.001:*" = "ABC.DEF.XYZ.001"
"*:001.*" = Error: Invalid mask
"*:00X:.*" = Error: Invalid mask
"*:00?:.*" = Error: Invalid mask

16. The colon pair may enclose date and time elements which are to be inserted in that position of that section of the name. The following elements may be used, and are not case-sensitive:

mm - month
dd - day
cc - century
yy - two-digit year
yyyy - four-digit year
jjj - Julian day
hh - hours
nn - minutes
ss - seconds
t - tenths of seconds
tt - hundredths of seconds

Examples:

"*:[mm-dd-yy]:.*" = "ABC.DEF[12-31-99].XYZ"
":ccyyjjj.:*.*" = "1999365.ABC.DEF.XYZ"
"*:.(mm-dd-ccyy)-[hh;mm;ss.tt]:.*" = ABC.DEF.(12-31-1999)-[23;59;59.99].XYZ

17. Wildcards may be placed inside the colon pair.

Examples:

":mmddyy-*-001:.*" = "123199-ABC.DEF-001.XYZ"
"*:(001)????:.*" = "ABC(001).DEF.XYZ"

18. The colon pair and the insertion pair may be nested.

Examples:

"*<.Seq=:001:>.*" = ABC.DEF.Seq=001.XYZ"
"*:<.Seq>=001:.*" = ABC.DEF.Seq=001.XYZ"
"*<.mm=:mm: dd=:dd: yy=:yy:>.* = "ABC.DEF.mm=12 dd=31 yy=99.XYZ"
"*:<.mm>=mm<.dd>=dd<.yy>=yy:.* = "ABC.DEF.mm=12.dd=31.yy=99.XYZ"

915 views      
Thread locked
 

Messages in this Thread

 
96,637 Postings in 12,231 Threads, 350 registered users, 72 users online (0 registered, 72 guests)
Index | Admin contact |   Forum Time: Mar 28, 2024 - 1:44 pm UTC  |  Hits:62,368,698  (21,095 Today )
RSS Feed