1 (edited by Stefan 2007-04-22 01:12:56)

Topic: Invert elements, Part1-Part2 => Part2 - Part1

Invert elements, delete some

If you want to exchange some part of an file name, maybe
  from "Song-Artist.mp3" to "Artist-Song.mp3"
  or from "Name,Given name.doc" to "Given name,Name.doc"
  then read this:

For example

   From:
   Song Title 1 - Singer - Site.mp3
   Title 2 - Singer.mp3

   To:
   Singer - Song Title 1.mp3
   Singer - Title 2.mp3


   Use the expression:
   %b[2] - %b[1].%e




How does it work ?

   The "[]" modifier "splits" the associated string in array elements
   following the characters specified in "Options/Modifications" (or given as second parameter to "[]").

   Each "substring" is reachable through its index.

   In this case, if '-' is one of the separators in "Options/Modifications":
   %b     gives "Song Title 1 - Singer - Site"
   %b[1]  gives "Song Title 1"
   %b[2]  gives "Singer"
   %b[3]  gives "Site"

   if the index is negative, the numbering start from the end:
   %b[-1] gives "Site"
   %b[-2] gives "Singer"
   %b[-3] gives "Song Title 1"

   %e, the file extension is "mp3"




   So, following the expression on "Song Title 1 - Singer - Site.mp3":
   %b[2]                     gives "Singer"                                  [part 2 of the original name]
   %b[2] -                   gives "Singer - "                              [we add an - sign]
   %b[2] - %b[1]         gives "Singer - Song Title 1"             [we add the first part from the original name]
   %b[2] - %b[1].        gives "Singer - Song Title 1."            [we add an dot to set the extension apart]
   %b[2] - %b[1].%e   gives "Singer - Song Title 1.mp3"      [we add the original extension by %e ,  an * sign would also fit]




----------------
For the example
"Name, Given name.doc" to "Given name, Name.doc"
add the comma sign to "Options/Modifications".
The standard character specified in "Options/Modifications" is an - sign.

But we can also add an second parameter to "[]" on the fly.

For from "Name, Given name.doc"
to "Given name, Name.doc"

use the expression %b[2,","], %b[1,","].*

The ","   in [2,","]   tells Siren to use the coma as  separator too.

So for  "Name,Given name.doc"
%b[2]  gives nothing because the standard splitting character is an - . And we didn't have them in the original name.
%b[2,","]                   gives    "Given name"
%b[2,","],                  gives    "Given name,"                       [we add an coma,  add an trailing blank if you want to set Given name and Name apart]
%b[2,","],%b[1,","]     gives   "Given name,Name"               [we add the first part of the original name]
%b[2,","],%b[1,","].    gives   "Given name,Name."              [we add an dot]
%b[2,","],%b[1,","].*  gives   "Given name,Name.doc"         [we add the original extension]




   For more details just download Siren at http://www.scarabee-software.net/en/siren.html and consult the help.
   No installation needed, unzip and run.    <Here> you can see some screen shots of Siren.