For example if the user wanted to rename a collection of files in terms of the parent directory, they should be able to use a special variable inside $With/$Paste to reference that item:
For these varibles, let's use _ and CAPITAL letters. This will distinguish from named group references.
_D: the parent directory name
_I: the allocated 1 based index. Actually the user could specify ${_I:n}, where n represents the number of leading zeros.
We could also have a field mapper. For example, lets say files contain dates, we might decide we'd like to map month numbers tomonth names. So insert a capture, the user would do this:
where the * means map that field. So which map function? The :fn specifies the mapper function. To implement this, we'd need to add a Mappers parameter that is a hashtable, mapping function names (the fn) to script-block.
Since the use of a hashtable would be a common pattern, we could use alterative notation to simply look up the value in a user defined hashtable.
-Paste/With '(${year}-*{mon@lookup}-${day})'
The @ means look up the value in a hash table identified by 'lookup'. We would need to introduce a new variable -Lookup
All this functionality would typically be used by developers writing new functions that sit atop Rename-Many.
For example if the user wanted to rename a collection of files in terms of the parent directory, they should be able to use a special variable inside $With/$Paste to reference that item: For these varibles, let's use _ and CAPITAL letters. This will distinguish from named group references.
We could also have a field mapper. For example, lets say files contain dates, we might decide we'd like to map month numbers tomonth names. So insert a capture, the user would do this:
with a mapper we could do something like
where the * means map that field. So which map function? The :fn specifies the mapper function. To implement this, we'd need to add a Mappers parameter that is a hashtable, mapping function names (the fn) to script-block.
Since the use of a hashtable would be a common pattern, we could use alterative notation to simply look up the value in a user defined hashtable.
The @ means look up the value in a hash table identified by 'lookup'. We would need to introduce a new variable -Lookup
All this functionality would typically be used by developers writing new functions that sit atop Rename-Many.