You are not logged in.
Hi
Thanks to Den4b answering all questions, I encountered that the RegEx motor of Renamer's script-editor has some lmitations, and I need to bypass them.
Someone helped me to design the regular expression pattern below written in PHP.
^(?P<artist>.+?(?=\s-\s)) # artist with pos. lookahead
\s-\s # space - space
(?P<title>.+?(?=(?:\(?Feat\.)|$)) # title with pos. lookahead
\(? # optional open parenthesis
(?P<artist2>Feat\.[^()\n]+)? # artist2 with Feat. before
\)? # optional closing parenthesis
(?P<subtitle>.+)?$ # optional subtitle
https://regex101.com/r/iQ2aG4/1
I currentlly develop in .Net environment, my intention is to translate the pattern to C#-syntax, develop a very simple CLI app that takes a string to perform the regex replacement and return/print the resulting string, then find a way to use that app from Renamer.
My question is, from the script-editor I could run that external CLI app?.
If yes, how I could run the app and manage their output/return value from the script-editor?.
Last edited by Elektro (2016-02-23 13:41)
Offline
Wiki function reference:
ReNamer:Pascal_Script:Functions#Process_Execution
Sample usage:
var
Output: String;
begin
if ExecConsoleApp('tool.exe', Output) = 0 then
FileName := Output + FileName;
end.
Offline
@den4b
Really thankyou!
Its time for me to take a long read at your wiki to avoid these kind of questions. sorry anout that!.
Have a nice day.
Offline
I need some help...
Which is the working directory when a script is launched?.
In line:
if ExecConsoleApp('tool.exe', Output) = 0 then
I need to write a relative (not absolute not environment variables) path, starting from a known Renamer installation folder, like this:
if ExecConsoleApp('.\Tools\App.exe', regexconOutput) = 0 then
On where the imaginary working dir starts at "C:\Program Files (x86)\ReNamer\" so I'm pointing to "C:\Program Files (x86)\ReNamer\Tools"
EDIT: I seen the GetApplicationPath function, there is not a function that justs returns the directory path without the filename?.
Also the double-quotes could be escaped or I'm forced to do ugly appends?.
if ExecConsoleApp( '"' + 'C:\Program Files (x86)\ReNamer\Tools\RegexCon.exe' + '"' ) = 0 then
Last edited by Elektro (2016-02-26 17:41)
Offline
Done:
if ExecConsoleApp('"'+ WideExtractFileDir(GetApplicationPath()) + '\Tools\RegexCon.exe' + ...
However, I'm not sure if this will take much execution time and maybe exists a proper solution than calling two funcs. (my script will run on +400.000 files)
Last edited by Elektro (2016-02-26 17:45)
Offline
Which is the working directory when a script is launched?
The application that you execute via ExecConsoleApp will have the same current working directory as the calling application (i.e. ReNamer). Normally this would be ReNamer's root directory, unless you change.
Also the double-quotes could be escaped or I'm forced to do ugly appends?
You can create a simple function to enquote parameters, for example:
function Enquote(const Parameter: String): String;
begin
Result := '"' + Parameter + '"';
end;
Note, this is a simple example! A proper escape function should also escape contained quotes.
I'm not sure if this will take much execution time and maybe exists a proper solution than calling two funcs. (my script will run on +400.000 files)
Calling an external process for every file is going to be the longest operation there. There is no way around it.
Offline