You are not logged in.
Pages: 1
Hi,
great work so far. But as always things can be better.
It would be nice if Renamer could handle font-files, maybe you can use open source freetype2 for that.
Even better would be an general plugin interface for the extraction of meta-tags.
Offline
Hi DeFransen and welcome to the community
Even better would be an general plugin interface for the extraction of meta-tags.
Perhaps you can do this already on your own? => http://www.den4b.com/forum/viewtopic.php?pid=2290#p2290
Please tell us how it works.
-
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
Sure I can do it, and I've already solved that Problem for myself.
But I do use a selfwritten python script with the fonforge python-plugin, since it was more easy and faster to implement it that way and I would have to write an external script or program anyway to create the output the Pascal script can read in.
I just thought it would be nice to have an plugin system, so that people like me can contribute to the project and users without programming knowledge can reuse such solutions.
Offline
I just had another Idea: It should be possible to create a kind of plugin-system with the help of a Pascal script.
I'll work on that.
Did you mean this already with your reply?
Offline
Did you mean this already with your reply?
I only want to show you an possibility with this script of Denis
But if you can wrote an script already you wouldn't need ReNamer for that anymore. IMHO
(one could use an MsgBox as preview)
Another idea is to use ReNamer to export the names,
modify them with the script possibilities of an editor (or store them as file and execute your script on that)
and import that modified names again. http://www.den4b.com/forum/viewtopic.php?pid=1799#p1799
Only suggestions, i wont prevent Denis to reply on his own.
Last edited by Stefan (2008-11-10 21:51)
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
It's finished.
The script reads a config file, which defines tagnames, the tool to execute and a RegEx to retrive the desired info from the output of the tool. Then it looks for known tags in the filename and replaces them.
Where can I upload it?
Offline
Congratulation
It's finished.
The script ...
Where can I upload it?
Right here? ??? ... use the [_code][_/code] Button and put your script in between?
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
Alright here it is:
The Pascal-Script: tagTools.pas
{Get Meta-Tags With External Tools}
const ttPath = 'D:\Programme\ReNamer\tagTools';
var
cfg, tagName, tagRegex: WideString;
toolCmd, cmdParams, output: String;
knownTags, tagArray, strArray: TStringsArray;
ec: Cardinal;
i, j: Integer;
function Arr2Str(a: TStringsArray): WideString;
var ret: WideString; c: Integer;
begin
ret := '';
if Length(a) > 0 then begin
for c := 0 to Length(a)-1 do begin
ret := ret+a[c];
end;
end;
Result := ret;
end;
function rMatch(const Inp, Find: WideString): TStringsArray;
var arr1,arr2, ret: TStringsArray; c: Integer;
begin
SetLength(ret,0);
arr1 := MatchesRegEx(Inp, Find, True);
if Length(arr1) > 0 then for c := 0 to Length(arr1)-1 do begin
arr2 := SubMatchesRegEx(arr1[c], Find, True);
SetLength(ret,Length(ret)+1);
ret[Length(ret)-1] := Arr2Str(arr2);
end;
Result := ret;
end;
begin
tagArray := rMatch(FileName, ':\[([^\]]*)\]:');
if (Length(tagArray) > 0) then begin
cfg := FileReadContent(ttPath+'\tagTools.csv');
knownTags := rMatch(cfg, '([^\r\n]*)[\r\n]');
for i := 0 to Length(knownTags)-1 do for j := 0 to Length(tagArray)-1 do begin
if WidePos(';',tagArray[j]) > 0 then begin
strArray := WideSplitString(tagArray[j],';');
tagName := strArray[0];
cmdParams := strArray[1];
end else begin
tagName := tagArray[j];
cmdParams := '';
end;
if (WidePos(tagName,knownTags[i]) = 1) then begin
strArray := WideSplitString(knownTags[i],';');
tagRegex := strArray[2];
toolCmd := WideReplaceStr(strArray[1],'%params%',cmdParams);
toolCmd := WideReplaceStr(toolCmd,'%newName%',ReplaceRegEx(FileName,':\[[^\]]*\]:','',True,True));
toolCmd := WideReplaceStr(toolCmd,'%newBName%',WideExtractBaseName(ReplaceRegEx(FileName,':\[[^\]]*\]:','',True,True)));
toolCmd := WideReplaceStr(toolCmd,'%newExt%',WideExtractFileExt(ReplaceRegEx(FileName,':\[[^\]]*\]:','',True,True)));
toolCmd := WideReplaceStr(toolCmd,'%ttPath%',ttPath);
toolCmd := WideReplaceStr(toolCmd,'%fName%',FilePath);
toolCmd := WideReplaceStr(toolCmd,'%fPath%',WideExtractFilePath(FilePath));
toolCmd := WideReplaceStr(toolCmd,'%fBName%',WideExtractBaseName(FilePath));
toolCmd := WideReplaceStr(toolCmd,'%fExt%',WideExtractFileExt(FilePath));
ec := ExecConsoleApp(toolCmd, output);
//ShowMessage(toolCmd+'|'+output);
if (ec = 0) then begin
if (WidePos('$',tagRegex)=1) then begin
WideDelete(tagRegex,1,1);
strArray := rMatch(output, tagRegex);
if (Length(strArray) > 0) then begin
FileName := strArray[0];
end;
end else begin
strArray := rMatch(output, tagRegex);
if (Length(strArray) > 0) then begin
FileName := ReplaceRegEx(FileName,':\['+tagName+'[^\]]*\]:',strArray[0],True,True);
end;
end;
end;
end;
end;
FileName := ReplaceRegEx(FileName,':\[[^\]]*\]:','',True,True);
end;
end.
The config file for the script: tagTools.csv
fontFamily;"%ttPath%\ftdump.exe" -n "%fName%";family\W*([\w -]*)
fontStyle;"%ttPath%\ftdump.exe" -n "%fName%";style\W*([\w -]*)
fontPSName;"%ttPath%\ftdump.exe" -n "%fName%";postscript\W*([\w -_]*)
fontType;"%ttPath%\ftdump.exe" -n "%fName%";FreeType driver\W*([\w]*)
fontFixedWidth;"%ttPath%\ftdump.exe" -n "%fName%";fixed width\W*([\w]*)
fontGlyphs;"%ttPath%\ftdump.exe" -n "%fName%";glyph count\W*([\w]*)
fontCopyright;"%ttPath%\ftdump.exe" -n "%fName%";copyright\s*\[Microsoft\]\W*"([^"]*)"
fontMSName;"%ttPath%\ftdump.exe" -n "%fName%";full name\s*\[Microsoft\]\W*"([^"]*)"
fontVendor;"%ttPath%\ftdump.exe" -n "%fName%";manufacturer\s*\[Microsoft\]\W*"([^"]*)"
pdfTitle;"%ttPath%\pdfinfo.exe" "%fName%";Title:\s*([^\r\n]*)
pdfCreator;"%ttPath%\pdfinfo.exe" "%fName%";Creator:\s*([^\r\n]*)
pdfProducer;"%ttPath%\pdfinfo.exe" "%fName%";Producer:\s*([^\r\n]*)
pdfCreaDate;"%ttPath%\pdfinfo.exe" "%fName%";CreationDate:\s*([\d\./]*)
pdfCreaTime;"%ttPath%\pdfinfo.exe" "%fName%";CreationDate:.*?([\d:]*)\s*[\r\n]
pdfModDate;"%ttPath%\pdfinfo.exe" "%fName%";ModDate:\s*([\d\./]*)
pdfModTime;"%ttPath%\pdfinfo.exe" "%fName%";ModDate:.*?([\d:]*)\s*[\r\n]
pdfPages;"%ttPath%\pdfinfo.exe" "%fName%";Pages:\s*(\d*)
pdfPageSize;"%ttPath%\pdfinfo.exe" "%fName%";Page size:\s*([\d\sx]*) pt
pdfPageFormat;"%ttPath%\pdfinfo.exe" "%fName%";Page size:.*\((.*)\)
2png;cmd /c "("%ttPath%\ImageMagick\convert.exe" %params% "%fName%" "%fPath%%newBName%.png")&&(echo %newBName%.png)";$([^\r\n]*)
2gif;cmd /c "("%ttPath%\ImageMagick\convert.exe" %params% "%fName%" "%fPath%%newBName%.gif")&&(echo %newBName%.gif)";$([^\r\n]*)
2bmp;cmd /c "("%ttPath%\ImageMagick\convert.exe" %params% "%fName%" "%fPath%%newBName%.bmp")&&(echo %newBName%.bmp)";$([^\r\n]*)
2tff;cmd /c "("%ttPath%\ImageMagick\convert.exe" %params% "%fName%" "%fPath%%newBName%.tiff")&&(echo %newBName%.tiff)";$([^\r\n]*)
The tools must be downloaded by yourself this way:
ftdump and pdfinfo are from the GnuWin32-Project http://gnuwin32.sourceforge.net
ImageMagick is located at http://www.imagemagick.org
To make it work correctly you'll have to adjust the ttPath variable to point to the folder where the config file is in. Within the config file you'll have to adjust the paths to the tools or put them in the ttPath aswell.
I've included ImageMagick to show the batch processing possibilities of Renamer, but there are some limitations. The conversion takes place within preview, which could be surprising for some users (especialy if you'll have auto preview enabled) and can lead to data loss. Renamer will continue to work on the original file, so multiple conversions are impossible and the script should be executed as last.
Offline
WOW
this code looks impressive, ...and i think it IS.
Many thanks for sharing it!
-
I am glad someone gives kudos to Denis while using his tool that heavy way. Thank you.
I hope you are around if some user have questions about PascalScript ? Would be great.
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 your input DeFransen
I'm sure that it would helpful for some users!
Offline
Pages: 1