Difference between revisions of "ReNamer:Rules:Rearrange"

From den4b Wiki
Jump to navigation Jump to search
(Created page with '== Basic uses == === Example === {| class="prettytable" | <center>'''Change from-'''</center> | <center>'''To-'''</center> |- | King, Stephen Cook, Robin Rami, Sam Pride and...')
 
m (Markup cleanup)
(45 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Basic uses ==
+
{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Replace|next=ReNamer:Rules:Extension}}
=== Example ===
 
  
{| class="prettytable"
+
== Rearrange rule  ==
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
  
|-
+
[[Image:RearrangeRule.png|center]]
| King, Stephen
 
 
 
Cook, Robin
 
 
 
Rami, Sam
 
  
Pride and Prejudice, The
+
This rule allows you to chop up the existing file name and reuse any/all of the parts in any order to compose a new name.
| Stephen King
 
  
Robin Cook
+
*You can also add your own text, or use meta tags while composing the new name.
 +
*You can also use the whole original name, and insert literal text (or meta tags) around it.<br>
  
Sam Rami
+
The parameters are as follows:  
 
 
The Pride and Prejudice
 
 
 
|}
 
'''Task:''' Switch the name and surname''', '''and remove comma.
 
 
 
 
 
'''Setting:'''
 
 
 
Delimiter: ", " (without the quotes)
 
 
 
New Order: $2 $1
 
 
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
  
 +
{| class="wikitable"
 
|-
 
|-
| Words sample 1234 07-07-07
+
! Parameter
| 1234 Words sample 07-07-07
+
! Description
 
 
|}
 
'''Task:''' Move a word to a new position.
 
 
 
 
 
'''Setting:'''
 
 
 
Delimiter: " " (only a space, without the quotes)
 
 
 
New Order: $3 $1 $2 $4
 
 
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
 
 
 
|-
 
|-
| 01 - Afilename.zip
+
| Split using
 
+
|  
002 - Bfilename.zip
+
Specifies how to split the existing name into parts.  
 
 
0003 - Cfilename.zip
 
| Afilename.zip
 
 
 
Bfilename.zip
 
  
Cfilename.zip
+
*You can use only one of the three options at a time (you cannot combine the chopping methods)
  
|}
+
For detailed explanation of split methods please look below at the [[#Split options explained|split options explained]] section.
'''Task:''' Get rid of the numbers, hyphen and space at the beginning.
 
 
 
 
 
'''Setting:'''
 
 
 
Delimiter: "- " (without the quotes)
 
 
 
New Order: $2
 
 
 
 
 
'''Remarks:'''
 
 
 
# Note that the delimiter contains a space. If only a hyphen is used as delimiter, then a space would be left out in the beginning of the name, which you would have to trim separately.
 
# The '''Delete''' rule also would work (in ''right-to-left ''mode). But the '''Rearrange''' rule also allows you to add any string to the truncated names.
 
 
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
  
 
|-
 
|-
| TEST.aaa.bbb.100.ext
+
| Right-to-left
| aaa.bbb.100.TEST.ext
+
|  
 
+
If selected, the numbering starts from right.  
|}
 
'''Task: '''Move the first part to the end.
 
 
 
  
'''Setting:'''
+
*The characters of the original names are counted from right (the count begins with 1)  
 
+
*The chopped parts will also be numbered from right ($1, $2, etc.)
Delimiter: "." (without the quotes)
 
 
 
<nowiki>Skip Extension [X]</nowiki>
 
 
 
New Order: $2.$3.$4.$1
 
 
 
 
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
  
 
|-
 
|-
| Ring ring_ABBA.mp3
+
| [[Image:PlusButton.png]]
 
+
| Add a separator for additional delimiters. The separator is a "{{Pipe}}" (vertical pipe) character, which can also be entered manually.
Material girl_Madonna.mp3
 
| ABBA - Ring Ring.mp3
 
 
 
Madonna - Material girl mp3
 
 
 
|}
 
'''Task: '''Move the artists’ name from end to the beginning, and change the name format.
 
 
 
 
 
'''Setting:'''
 
 
 
Delimiter: "_" (without the quotes)
 
 
 
<nowiki>Skip Extension [ ]</nowiki>
 
 
 
New Order: $2 - $1
 
 
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
 
 
 
|-
 
|-
| DSC_0001-1.jpg
+
| New pattern
 
+
|  
DSC_0001-10.jpg
+
How to compose the new name from the parts created from the original name (see above).
 
 
DSC_0001-2.jpg
 
| 1-DSC_0001.jpg
 
 
 
10-DSC_0001.jpg
 
 
 
2-DSC_0001.jpg
 
 
 
|}
 
'''Task:''' Move the numbers to the beginning.
 
 
 
 
 
'''Setting:'''
 
 
 
Delimiter: "-" (without the quotes)
 
 
 
New Order: $2-$1
 
 
 
 
 
=== Example ===
 
  
{| class="prettytable"
+
*You can add meta tags and literal text wherever you want.
| <center>'''Change from-'''</center>
+
*$0 refers to the whole original name. This allows you to quickly compose a new name by inserting a string at the beginning and/or end.
| <center>'''To-'''</center>
 
  
 
|-
 
|-
| family_001.jpg
+
| [[Image:ReNamer Insert Meta Tag Button.png]]
 
+
| Click the button to see a list of [[ReNamer:Meta Tags|meta-tags]]. Select any meta tag to insert it in the new name template.
work_023.jpg
 
 
 
friend_098.jpg
 
| family_sent_001.jpg
 
 
 
work_sent_023.jpg
 
 
 
friend_sent_098.jpg
 
 
 
 
|}
 
|}
'''Task:''' Insert "sent_" before the last 3 digits.
 
 
'''Setting:'''
 
 
Delimiter: "_" (without the quotes)
 
 
New Order: $1_sent_$2
 
  
 +
=== Split options explained ===
  
'''Remarks:'''
+
{| class="wikitable"
 
 
The '''Insert''' rule also would work (in ''right-to-left ''mode). But the '''Rearrange''' rule also allows you to add any string to the names.
 
 
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
 
 
 
|-
 
|-
| Sting - All This Time.mp3
+
! Option
| All This Time.mp3
+
! Description
 
 
|}
 
'''Task:''' Remove the name of the artist (delete text until hyphen).
 
 
 
 
 
'''Setting:'''
 
 
 
Delimiter: "- " (without the quotes)
 
 
 
New Order: $2
 
 
 
 
 
'''Remarks:'''
 
 
 
# Note the space after the hyphen. If we use just a “-“ as delimiter, the second token would be left with a space in front, which we will have to trim separately.
 
# Even the '''Delete''' rule would have worked (in ''right-to-left ''mode). But the '''Rearrange''' rule also allows you to add any string to the new name.
 
 
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
 
 
 
|-
 
|-
| 08. Madonna - Like A Prayer.wma
+
| Delimiters
 
+
|  
08.-Madonna - Like A Prayer.wma
+
Chop the name where the delimiter occurs.
 
 
08 Madonna – Like A Prayer.wma
 
| Madonna – Like A Prayer.wma
 
 
 
|}
 
'''Task:''' Remove the track numbers (and any separator symbol after that) from the beginning of the filenames:
 
 
 
 
 
'''Setting:'''
 
 
 
Delimiter: "Mad" (without the quotes)
 
 
 
New Order: Mad$2
 
 
 
  
'''Remarks: '''
+
*The delimiter can be a single character or a string.
 +
*The chopped parts do <u>''not''</u> contain the delimiters (they are omitted totally)
 +
*Spaces, numbers and symbols are treated like normal characters.
 +
*Several delimiters can be used at a time. Use the {{pipe}} character to separate them.
 +
*The chopped parts are numbered from left, as $1, $2, $3, etc.
 +
:The same parts can be referred from the end as $-1, $-2, $-3, etc.
 +
*If the delimiter occurs at the very beginning of the name, the resultant $1 contains nothing (because there is nothing on the left side of the delimiter).
 +
:The same is true if an delimiter match at the very end of the name, the resultant $n contains nothing.
  
We chose the string “Mad” as delimiter because it does not occur anywhere else in the names. The unwanted characters on the left are assigned to token $1, which we will not omit in the new name. However, there is an undesired side-effect: ReNamer removes “Mad” string from the token $2 because it is the delimiter. Therefore, we have to manually add that missing string “Mad” to $2, to restore the names.
+
<span style="color: red;">'''Warning:'''</span> The number of parts into which the filename is broken down depends solely on the number of delimiters in the filename. If you reference fewer parts in the output pattern that the number of available parts - not referenced parts will be lost! For example, take filename "Artist - Title" and to swap them around one would use " - " as a delimiter and "$2 - $1" as a new pattern which will result in "Title - Artist", but if some filename appears with more dashes like "Artist - Title - Album" the result will also be "Title - Artist" and last part will be lost. To make sure that no parts are lost use '''Exact pattern of delimiters''' option instead.
 
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
  
 
|-
 
|-
| <nowiki>Name XXX [0001].jpg</nowiki>
+
| Positions
| 0001 - Name XXX.jpg
+
|  
 +
Chop the name at the indicated position (the position count begins with 1).  
  
|}
+
*If you enter position '''n''', ReNamer will chop the '''n'''-th character and all characters beyond that in a separate piece.
'''Task: '''Move the number to front, and remove the square brackets.
+
*Spaces, numbers and symbols are treated like normal characters.
 
+
*No part of the original name is omitted during chopping.  
 
+
*You can enter multiple positions. Separate them with the '''*&#124;*''' sequence.
'''Setting:'''
+
*The chopped parts are numbered from left, as $1, $2, $3, etc.
  
Delimiter: <nowiki>"[|]" (without the quotes)</nowiki>
+
:The same parts can be referred from the end as $-1, $-2, $-3, etc.
 
 
New Order: $2 - $1
 
 
 
 
 
'''Remarks:'''
 
 
 
# The | character is used to separate the two delimiters.
 
# The second delimiter “]” will not produce a token. It is included only to remove it from the new name.
 
 
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
  
 
|-
 
|-
| Eine kleine Nachtmusik.mp3
+
| Exact pattern of delimiters
 
+
|  
Don Giovanni.mp3
+
Chop the name using the exact pattern (sequence) of the delimiters.  
| Mozart - Eine kleine Nachtmusik (6.37).mp3
 
 
 
Mozart - Don Giovanni (4.5).mp3
 
 
 
|}
 
'''Task: '''Add composer name and duration to an mp3 file,''' '''as prefix and suffix, respectively
 
 
 
 
 
'''Setting:'''
 
 
 
Positions: 1
 
  
New Order: Mozart - $2 (:AudioDuration:)
+
With this option you basically define how many parts you want the filename to be split into and the order in which the delimiters must occur. If you specify 1 delimiter then you end up with exactly 2 parts, if you specify 2 delimiters you'll get 3 parts, and so on.  
 
 
 
 
'''Remarks:'''
 
 
 
# This can also be done by using the '''Insert''' rule. However, you have to use that rule twice (once for prefix and the second time for the suffix). On the other hand, the '''Rearrange''' rule allows you to add both in a single stroke. Besides, you can see the structure of the new name.
 
# When the original name is sliced at position 1, there is no characters on the left side; so the $1 token is a blank. The ''entire'' name is copied into the $2 token. This is a great trick to compose new name using the ''whole'' original name.
 
 
 
== Advanced uses ==
 
=== Example ===
 
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
 
 
|-
 
| <nowiki>Artist - Title [Time 4 02 Cold] [2004].mpg</nowiki>
 
| <nowiki>Artist - Title [2004].mpg</nowiki>
 
  
 
|}
 
|}
'''Task:''' Remove the string '''<nowiki>[Time ???? Cold]</nowiki>''' from the file name.
 
 
 
'''Setting:'''
 
 
<nowiki>Delimiter: " [T|d] " </nowiki>(without the quotes)
 
 
New Order: $1 $3
 
 
 
'''Remarks:'''
 
 
# The '''|''' character separates the two delimiters.
 
# Notice that we have included spaces in the delimiters, so that they do not end up as part of the tokens.
 
# We have selected two ''different'' delimiters to represent the beginning- and the end of the string we want to remove. Thus '''''whatever''''' lies between the two delimiters is converted into a token. This token is then omitted in the new name. This works just like using wildcards for the string (or a RegEx pattern).
 
 
=== Example ===
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
 
|-
 
| Song title1 – Artist1 (Album1).mp3
 
 
Song title2 – Artist1 (Album1).mp3
 
 
Song title1 – Artist1 (Album2).mp3
 
 
Song title2 – Artist1 (Album2).mp3
 
 
Song title1 – Artist2 (Album1).mp3
 
 
Song title1 – Artist2 (Album1).mp3
 
| D:\Artist1\Album1\Song title1.mp3
 
 
D:\Artist1\Album1\Song title2.mp3
 
 
D:\Artist1\Album2\Song title1.mp3
 
 
D:\Artist1\Album2\Song title2.mp3
 
 
D:\Artist2\Album1\Song title1.mp3
 
 
D:\Artist2\Album1\Song title2.mp3
 
 
|}
 
'''Task: '''The file names contain artist name, album name and track name.
 
 
Sort them into separate folders as follows:
 
 
# Create a separate folder for each artist.
 
# For each artist, create a subfolder for each album.
 
# Move each file in the corresponding folder.
 
 
'''Setting:'''
 
 
Delimiter: " - | (|)" (without the quotes)
 
 
<nowiki>Skip Extension [x]</nowiki>
 
 
New pattern: D:\$2\$3\$1
 
 
 
'''Remarks:'''
 
 
# Note that the delimiters contain spaces and symbols, so that only text remains in the tokens.
 
# The last delimiter ) does not produce a token. It is added just to strip the closing bracket from the last token.
 
# Instead of “D:”, a relative path (such as '''..\..\''') can be added to the front.
 
 
=== Example ===
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
 
|-
 
| DSC_0001.jpg
 
 
DSC_0002.jpg
 
 
DSC_0003.jpg
 
 
DSC_0004.jpg
 
 
<center>'''…..'''</center>
 
 
DSC_0125.jpg
 
| D:\photos\trip\2009_10_21\DSC_0001.jpg
 
 
D:\photos\trip\2009_10_21\DSC_0002.jpg
 
 
D:\photos\trip\2009_10_21\DSC_0003.jpg
 
 
D:\photos\trip\2009_10_22\DSC_0004.jpg
 
 
<center>'''………'''</center>
 
 
D:\photos\trip\2009_10_25\DSC_0125.jpg
 
 
 
 
 
|}
 
'''Task: '''Sort digital photos in different folders based on the “Date taken” for each photo.
 
 
 
'''Setting:'''
 
 
Delimiter: "D" (without the quotes)
 
 
<nowiki>Skip Extension [x]</nowiki>
 
 
New pattern: D:\photos\trip\:EXIF_Date:\D$2
 
 
 
'''Remarks:'''
 
 
# Note that this EXIF data is contained in the meta tag of each photo, not in the file name.
 
# The meta tag ''':EXIF_Date: '''is replaced by the actual “date taken” for each photo. Thus all photos taken on the same date will be moved to the same folder (which is named after that date).
 
# The actual name of the folder would depend upon the current settings for the system date format. (If you want the folders to be named after a different date format, first change the system date format, using the '''Regional and Language Options''' option in the '''Control Panel'''.)
 
 
=== Example ===
 
 
{| class="prettytable"
 
| <center>'''Change from-'''</center>
 
| <center>'''To-'''</center>
 
 
|-
 
| title.text1.text2.extension
 
 
title.text1.text2.text3.extension
 
| title.text1.extension
 
 
title.text1.text2.extension
 
 
|}
 
'''Task:''' Delete the last part of the base name (but the extension should remain). Note that the file names have different lengths, so you cannot slice the name at a particular position. The names have a different depths also (number of segments separated by dots).
 
 
 
'''Setting:''' The solution requires a stack of two different rules, as shown below:
 
 
1. '''Replace''' Rule
 
 
Find: "." (without the quotes)
 
 
Replace: “# “(without the quotes)
 
 
<nowiki>Last [X] </nowiki>(this is a temporary change; which will be eliminated in the second step)
 
 
 
2. '''Rearrange''' rule
 
 
Delimiter: "#" (without the quotes)
 
 
<nowiki>Skip Extension [X]</nowiki>
 
 
New Order: $1
 
  
 +
== Examples ==
  
'''Remarks: '''
+
This rule is so versatile that it can be used in a huge number of ways.
 +
Therefore its examples have been moved to a separate article [[ReNamer:Rules:Rearrange Examples|Rearrange Examples]].
  
We had to do this indirectly because the '''Rearrange''' rule cannot pick only the last dot as delimiter; and ignore the other dots. So we used a trick: we first changed the last dot into another character (using the '''Replace''' rule), and then use that new character as delimiter in the '''Rearrange''' rule.
+
[[Category:ReNamer]]

Revision as of 22:45, 5 June 2020

Rearrange rule

RearrangeRule.png

This rule allows you to chop up the existing file name and reuse any/all of the parts in any order to compose a new name.

  • You can also add your own text, or use meta tags while composing the new name.
  • You can also use the whole original name, and insert literal text (or meta tags) around it.

The parameters are as follows:

Parameter Description
Split using

Specifies how to split the existing name into parts.

  • You can use only one of the three options at a time (you cannot combine the chopping methods)

For detailed explanation of split methods please look below at the split options explained section.

Right-to-left

If selected, the numbering starts from right.

  • The characters of the original names are counted from right (the count begins with 1)
  • The chopped parts will also be numbered from right ($1, $2, etc.)
PlusButton.png Add a separator for additional delimiters. The separator is a "|" (vertical pipe) character, which can also be entered manually.
New pattern

How to compose the new name from the parts created from the original name (see above).

  • You can add meta tags and literal text wherever you want.
  • $0 refers to the whole original name. This allows you to quickly compose a new name by inserting a string at the beginning and/or end.
ReNamer Insert Meta Tag Button.png Click the button to see a list of meta-tags. Select any meta tag to insert it in the new name template.

Split options explained

Option Description
Delimiters

Chop the name where the delimiter occurs.

  • The delimiter can be a single character or a string.
  • The chopped parts do not contain the delimiters (they are omitted totally)
  • Spaces, numbers and symbols are treated like normal characters.
  • Several delimiters can be used at a time. Use the | character to separate them.
  • The chopped parts are numbered from left, as $1, $2, $3, etc.
The same parts can be referred from the end as $-1, $-2, $-3, etc.
  • If the delimiter occurs at the very beginning of the name, the resultant $1 contains nothing (because there is nothing on the left side of the delimiter).
The same is true if an delimiter match at the very end of the name, the resultant $n contains nothing.

Warning: The number of parts into which the filename is broken down depends solely on the number of delimiters in the filename. If you reference fewer parts in the output pattern that the number of available parts - not referenced parts will be lost! For example, take filename "Artist - Title" and to swap them around one would use " - " as a delimiter and "$2 - $1" as a new pattern which will result in "Title - Artist", but if some filename appears with more dashes like "Artist - Title - Album" the result will also be "Title - Artist" and last part will be lost. To make sure that no parts are lost use Exact pattern of delimiters option instead.

Positions

Chop the name at the indicated position (the position count begins with 1).

  • If you enter position n, ReNamer will chop the n-th character and all characters beyond that in a separate piece.
  • Spaces, numbers and symbols are treated like normal characters.
  • No part of the original name is omitted during chopping.
  • You can enter multiple positions. Separate them with the *|* sequence.
  • The chopped parts are numbered from left, as $1, $2, $3, etc.
The same parts can be referred from the end as $-1, $-2, $-3, etc.
Exact pattern of delimiters

Chop the name using the exact pattern (sequence) of the delimiters.

With this option you basically define how many parts you want the filename to be split into and the order in which the delimiters must occur. If you specify 1 delimiter then you end up with exactly 2 parts, if you specify 2 delimiters you'll get 3 parts, and so on.

Examples

This rule is so versatile that it can be used in a huge number of ways. Therefore its examples have been moved to a separate article Rearrange Examples.