Difference between revisions of "ReNamer:Examples of Rules"

From den4b Wiki
Jump to navigation Jump to search
(Swap names around)
(Change date format from DD-MM-YYYY to YYYY-MM-DD; reformatted rules)
 
Line 8: Line 8:
 
If the words are separated by spaced then you can use [[ReNamer:Rules:Delete|Delete]] rule, by deleting everything up to the next space.
 
If the words are separated by spaced then you can use [[ReNamer:Rules:Delete|Delete]] rule, by deleting everything up to the next space.
  
<pre>
+
# <tt>'''Delete''': <nowiki>Delete from Position 1 until Delimiter " " (skip extension)</nowiki></tt>
1) Delete: Delete from Position 1 until Delimiter " " (skip extension)
 
</pre>
 
  
 
Alternatively, this can be achieved with a [[ReNamer:Rules:RegEx|RegEx]] rule:
 
Alternatively, this can be achieved with a [[ReNamer:Rules:RegEx|RegEx]] rule:
  
<pre>
+
# <tt>'''RegEx''': <nowiki>Replace expression "\A[^\s]+\s*" with "" (skip extension)</nowiki></tt>
1) RegEx: Replace expression "\A[^\s]+\s*" with "" (skip extension)
 
</pre>
 
  
Examples:
 
 
{| class="wikitable"
 
{| class="wikitable"
 
! Input || Output
 
! Input || Output
Line 29: Line 24:
 
If the words are separated by spaced then you can use 3 [[ReNamer:Rules:Delete|Delete]] rules, with each one deleting everything up to the next space.
 
If the words are separated by spaced then you can use 3 [[ReNamer:Rules:Delete|Delete]] rules, with each one deleting everything up to the next space.
  
<pre>
+
# <tt>'''Delete''': <nowiki>Delete from Position 1 until Delimiter " " (skip extension)</nowiki></tt>
1) Delete: Delete from Position 1 until Delimiter " " (skip extension)
+
# <tt>'''Delete''': <nowiki>Delete from Position 1 until Delimiter " " (skip extension)</nowiki></tt>
2) Delete: Delete from Position 1 until Delimiter " " (skip extension)
+
# <tt>'''Delete''': <nowiki>Delete from Position 1 until Delimiter " " (skip extension)</nowiki></tt>
3) Delete: Delete from Position 1 until Delimiter " " (skip extension)
 
</pre>
 
  
 
Alternatively, this can be achieved with a single [[ReNamer:Rules:RegEx|RegEx]] rule:
 
Alternatively, this can be achieved with a single [[ReNamer:Rules:RegEx|RegEx]] rule:
  
<pre>
+
# <tt>'''RegEx''': <nowiki>Replace expression "\A[^\s]+\s+[^\s]+\s+[^\s]+\s*" with "" (skip extension)</nowiki></tt>
1) RegEx: Replace expression "\A[^\s]+\s+[^\s]+\s+[^\s]+\s*" with "" (skip extension)
 
</pre>
 
  
Examples:
 
 
{| class="wikitable"
 
{| class="wikitable"
 
! Input || Output
 
! Input || Output
Line 52: Line 42:
 
If the words are separated by spaced then you can use 3 [[ReNamer:Rules:Delete|Delete]] rules, with each one deleting everything up to the next space, but operating in "right-to-left" mode.
 
If the words are separated by spaced then you can use 3 [[ReNamer:Rules:Delete|Delete]] rules, with each one deleting everything up to the next space, but operating in "right-to-left" mode.
  
<pre>
+
# <tt>'''Delete''': <nowiki>Delete from Position 1 until Delimiter " " (right-to-left) (skip extension)</nowiki></tt>
1) Delete: Delete from Position 1 until Delimiter " " (right-to-left) (skip extension)
+
# <tt>'''Delete''': <nowiki>Delete from Position 1 until Delimiter " " (right-to-left) (skip extension)</nowiki></tt>
2) Delete: Delete from Position 1 until Delimiter " " (right-to-left) (skip extension)
+
# <tt>'''Delete''': <nowiki>Delete from Position 1 until Delimiter " " (right-to-left) (skip extension)</nowiki></tt>
3) Delete: Delete from Position 1 until Delimiter " " (right-to-left) (skip extension)
 
</pre>
 
  
 
Alternatively, this can be achieved with a single [[ReNamer:Rules:RegEx|RegEx]] rule:
 
Alternatively, this can be achieved with a single [[ReNamer:Rules:RegEx|RegEx]] rule:
  
<pre>
+
# <tt>'''RegEx''': <nowiki>Replace expression "\s*[^\s]+\s+[^\s]+\s+[^\s]+\Z" with "" (skip extension)</nowiki></tt>
1) RegEx: Replace expression "\s*[^\s]+\s+[^\s]+\s+[^\s]+\Z" with "" (skip extension)
 
</pre>
 
  
Examples:
 
 
{| class="wikitable"
 
{| class="wikitable"
 
! Input || Output
 
! Input || Output
Line 73: Line 58:
 
== Swap names around as "Last, First" to "First Last" ==
 
== Swap names around as "Last, First" to "First Last" ==
  
<pre>
+
# <tt>'''Rearrange''': <nowiki>Split by exact pattern of delimiters ", ", New pattern "$2 $1" (skip extension)</nowiki></tt>
1) Rearrange: Split by exact pattern of delimiters ", ", New pattern "$2 $1" (skip extension)
 
</pre>
 
  
Examples:
 
 
{| class="wikitable"
 
{| class="wikitable"
 
! Input || Output
 
! Input || Output
Line 86: Line 68:
 
|-
 
|-
 
| Mc Donald, John || John Mc Donald
 
| Mc Donald, John || John Mc Donald
 +
|}
 +
 +
== Change date format from DD-MM-YYYY to YYYY-MM-DD ==
 +
 +
# <tt>'''RegEx''': <nowiki>Replace expression "\b(\d{2})-(\d{2})-(\d{4})\b" with "$3-$2-$1" (skip extension)</nowiki></tt>
 +
 +
{| class="wikitable"
 +
! Input || Output
 +
|-
 +
| 31-03-2013 19-52-16.jpg || 2013-03-31 19-52-16.jpg
 +
|-
 +
| New Year 31-12-2014.jpg || New Year 2014-12-31.jpg
 
|}
 
|}

Latest revision as of 13:24, 28 December 2013

Arrow Return.png ReNamer  
{{{iparam}}} This article needs to be expanded!

This is a work in progress, keep adding more examples...

This article is a collection of examples of rules for various common tasks. Another set of examples specifically with a use of Rearrange rule is a available in a separate article: Rearrange Examples.

Remove first word separated by spaces

If the words are separated by spaced then you can use Delete rule, by deleting everything up to the next space.

  1. Delete: Delete from Position 1 until Delimiter " " (skip extension)

Alternatively, this can be achieved with a RegEx rule:

  1. RegEx: Replace expression "\A[^\s]+\s*" with "" (skip extension)
Input Output
Example File Name File Name

Remove first 3 words separated by spaces

If the words are separated by spaced then you can use 3 Delete rules, with each one deleting everything up to the next space.

  1. Delete: Delete from Position 1 until Delimiter " " (skip extension)
  2. Delete: Delete from Position 1 until Delimiter " " (skip extension)
  3. Delete: Delete from Position 1 until Delimiter " " (skip extension)

Alternatively, this can be achieved with a single RegEx rule:

  1. RegEx: Replace expression "\A[^\s]+\s+[^\s]+\s+[^\s]+\s*" with "" (skip extension)
Input Output
The quick brown fox jumps over the lazy dog fox jumps over the lazy dog

Remove last 3 words separated by spaces

If the words are separated by spaced then you can use 3 Delete rules, with each one deleting everything up to the next space, but operating in "right-to-left" mode.

  1. Delete: Delete from Position 1 until Delimiter " " (right-to-left) (skip extension)
  2. Delete: Delete from Position 1 until Delimiter " " (right-to-left) (skip extension)
  3. Delete: Delete from Position 1 until Delimiter " " (right-to-left) (skip extension)

Alternatively, this can be achieved with a single RegEx rule:

  1. RegEx: Replace expression "\s*[^\s]+\s+[^\s]+\s+[^\s]+\Z" with "" (skip extension)
Input Output
The quick brown fox jumps over the lazy dog The quick brown fox jumps over

Swap names around as "Last, First" to "First Last"

  1. Rearrange: Split by exact pattern of delimiters ", ", New pattern "$2 $1" (skip extension)
Input Output
Last, First First Last
Smith, John John Smith
Mc Donald, John John Mc Donald

Change date format from DD-MM-YYYY to YYYY-MM-DD

  1. RegEx: Replace expression "\b(\d{2})-(\d{2})-(\d{4})\b" with "$3-$2-$1" (skip extension)
Input Output
31-03-2013 19-52-16.jpg 2013-03-31 19-52-16.jpg
New Year 31-12-2014.jpg New Year 2014-12-31.jpg