You are not logged in.
Could anyone give a novice user some advice about how to convert a filename that uses an ISBN-10 to one that uses an ISBN-13 via ReNamer?
Offline
You have to find a common pattern to extract the ISBN-10 number from your file names to work on them (have some examples?),
then add a '978' as prefix, drop the last digit, and find an algorithm (or a command line tool) to calculate the new 'check digit' (right word?)
EDIT
I think over there such a algorithm can be found > http://www.hahnlibrary.net/libraries/isbncalc.html
ISBN (International Standard Book Number) is a unique number assigned to each book.
ISBN-10:
    • The number has 9 information digits and ends with 1 check digit.
    • Assuming the digits are "abcdefghi-j" where j is the check digit. Then the check digit is computed by the following formula:
j = ( [a b c d e f g h i] * [1 2 3 4 5 6 7 8 9] ) mod 11
ISBN-13:
    • The number has 12 information digits and ends with 1 check digit.
    • Assuming the digits are "abcdefghijkl-m" where m is the check digit. Then the check digit is computed by the following formula:
m = ( [a b c d e f g h i j k l] * [1 3 1 3 1 3 1 3 1 3 1 3] ) mod 10 Don't know if that is correct.
.
Last edited by Stefan (2013-08-08 18:02)
Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Thanks for the response, Stefan. The files are all named <ISBN-10>.xml. I presume renaming them to <ISBN-13>.xml will require Pascal Script or some regular expression voodoo, neither of which I am capable of myself, alas.
Offline
The files are all named <ISBN-10>.xml.
That's pretty fine (read: easy)
But how is the number formate? With or without hyphens? Have a few examples for us? Also needed to check the 'check digit'.
I presume renaming them to <ISBN-13>.xml will require Pascal Script
Yes. I will see if I find some time to write this script (but first here comes the night,... and then some job to do...)
Maybe a colleague here wants to jump in in the meantime?
or some regular expression voodoo,
Rather not, since we have to do the math too.
neither of which I am capable of myself, alas.
Don't worry. Perhaps you are able to help Denis in other ways? (means: read my signature 
)
Stay tuned.
Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
I will certainly make a donation!
No dashes, so I'm working with filenames like 0262731312.xml, 026201212X.xml, and 0262134446.xml. (Desired output filenames for these would be 9780262731317.xml, 9780262012126.xml, and 9780262134446.xml, respectively.)
Thanks again!
Offline
Hmm, right now, I don't get it! I can't calculate the check digit correctly.
vim 7 GE-PACKT
ISBN-10: 3826617819
ISBN-13: 978-3826617812
Learning the vi and vim Editors
ISBN-10: 059652983X
ISBN-13: 978-0596529833
sed and awk (Nutshell Handbooks)
ISBN-10: 1565922255
ISBN-13: 978-1565922259
Regular Expressions Pocket Reference
ISBN-10: 0596514271
ISBN-13: 978-0596514273
First test:
//http://isbn-information.com/isbn-information/the-13-digit-isbn.html
//http://isbn-information.com/isbn-information/check-digit-for-the-13-digit-isbn.html
http://www.hahnlibrary.net/libraries/isbncalc.html
//ISBN-10 =     382661781 9
//ISBN-13 = 978 382661781 2
var
 sISBN: String;
 iCheck: Integer;
begin
  // Add your code here
  sISBN   := WideExtractBaseName(FileName);
  sISBN   := '978' + copy(sISBN, 1, length(sISBN)-1);
  iCheck  := StrToInt(sISBN);
  //    m  = ( [abcdefghijkl]  * [1313 1313 1313] ) mod 10
  iCheck  := (     iCheck      *   131313131313   ) mod 10;
  FileName := sISBN + IntToStr(iCheck)
           + WideExtractFileExt(FileName);
end.FROM:
0262731312.xml
3826617819.xml
059652983X.xml
1565922255.xml
0596514271.xml
I get:
9780262731313.xml
9783826617813.xml
9780596529833.xml
9781565922253.xml
9780596514273.xml
Second test:
var
 sISBN: String;
 iCheck,i,mul,tmp: Integer;
begin
  // Add your code here
  sISBN    := WideExtractBaseName(FileName);
  sISBN    := '978' + copy(sISBN, 1, length(sISBN)-1);
  mul      := 3;
  for i    := 1 to 12 do
  begin
    if mul  = 3 then 
       mul := 1 
    else
       mul := 3;
    tmp    := StrToInt(sISBN[i]);
    iCheck := iCheck + ( tmp * mul);
  end;
  showmessage('iCheck: '+ IntToStr(iCheck)+ ', Mod10: '+ IntToStr(iCheck mod 10) );
  FileName := sISBN + IntToStr(iCheck)
           + WideExtractFileExt(FileName);
end.FROM:
0262731312.xml
3826617819.xml
059652983X.xml
1565922255.xml
0596514271.xml
I get:
97802627313193.xml
978382661781211.xml
978059652983348.xml
978156592225469.xml
978059651427596.xml
I have to test some more....
.
Last edited by Stefan (2013-08-09 08:31)
Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
@Stefan, I was curious about how this works and I took a look. I've seen somewhere that for finishing the checksum (after the loop) they do this iCheck := (10 - (iCheck mod 10)) mod 10;
Oh! and iCheck := 0 before starting the loop. You know... renamer remembers the last value, I usually fall on this too.
If this software has helped you, consider getting your pro version. :)
Offline
I've seen somewhere that for finishing the checksum (after the loop) they do this iCheck := (10 - (iCheck mod 10)) mod 10;
It seams as this is the part to check the calculated check digit if that math results in zero, then the check digit is correct.
But I already know the correct ISBN-13 number from getting it from a online book store.
I just can do the math myself (right now... at some point I will get it... but have to do other job first...)
Oh! and iCheck := 0 before starting the loop.
Yes on my second test I will need that, thanks.
Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
OK, it seams
1.) my first attempt with """m = ( [abcdefghijkl] * [1313 1313 1313] ) mod 10""" will not work anyway in PascalScript.
2.) I don't understand the whole 'mod' math not very well, but tests certify that if the result of the 'mod' operation is not equals zero, 
(which would be a valid check sum then) then i have to do another math by subtracting my result from 10 to get the real check sum. 
(if I only had been spend more attention at school time)
So i have adjusted my second script by adding this second decision (if not zero), 
splitting the steps in separate operations, adjust the var name a bit and add some comments so maybe others can learn from this too.
This seams to work quite well. Please test yourself.
THE challenge:
No dashes, so I'm working with filenames like
0262731312.xml
026201212X.xml
0262134446.xml(Desired output filenames for these would be
9780262731317.xml
9780262012126.xml
9780262134446.xml
respectively.)
vim 7 GE-PACKT
ISBN-10: 3826617819
ISBN-13: 978-3826617812Learning the vi and vim Editors
ISBN-10: 059652983X
ISBN-13: 978-0596529833sed and awk (Nutshell Handbooks)
ISBN-10: 1565922255
ISBN-13: 978-1565922259Regular Expressions Pocket Reference
ISBN-10: 0596514271
ISBN-13: 978-0596514273
That means
FROM:
0262731312.xml
026201212X.xml
0262134446.xml
3826617819.xml
059652983X.xml
1565922255.xml
0596514271.xml
TO:
9780262731317.xml
9780262012126.xml
9780262134446.xml
9783826617812.xml
9780596529833.xml
9781565922259.xml
9780596514273.xml
USE PascalScript:
var
 sISBN: String;
 i,dig,mul,prod,sum,checksum: Integer;
begin
  //Get the ISBN-10 number from the file name:
  //here, the file name is ISBN only (have to be adjusted for other file names)
  sISBN    := WideExtractBaseName(FileName);
  //-------------------------
  //Adjust the ISBN-10 to become a ISBN-13:
  //drop last digit (the ISBN-10 check sum)
  sISBN    := copy(sISBN, 1, length(sISBN)-1);
  //add 978 (or 979) for ISBN-13 format
  sISBN    := '978' + sISBN;
  //-------------------------
  //calculate the ISBN-13 check sum (or: check digit)
  sum           := 0;
  mul           := 3;
  
  for i         := 1 to 12 do
    begin
        if mul   = 3 then 
           mul  := 1 
        else
           mul  := 3;
              
        dig     := StrToInt(sISBN[i]);
        prod    := (dig * mul);
        sum     := sum + prod;
    end;
  checksum      := sum mod 10;
  if checksum   <> 0 then
     checksum   := 10 - checksum;
  //-------------------------
  //compose new FileName:
  FileName      := sISBN + IntToStr(checksum) 
                 + WideExtractFileExt(FileName);
end.(OK, we don't have to really multiply the digit by 1 and can rearrange the code to drop this,... but I enjoy it works, so I don't care right now 
)
See our wiki for how to use PascalScript in den4b ReNamer >>> http://www.den4b.com/wiki/ReNamer:Rules:PascalScript
HTH? 
 (and works 
 )
Last edited by Stefan (2013-08-12 14:13)
Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
I recall similar calculations in a script for calculating the checksum digit for the EAN-13 barcode: ReNamer:Scripts:EAN-13.
When you are done with your script, you should put it on the wiki as well.
Offline