Extract Paths.
Posted: 11 Mar 2011 16:37
Hello people.
I'm trying to readfile find pathnames for files, strip files out of paths, paths out of pathnames, base drives only out of pathnames, first parent folders out of pathnames so I can get reports out of documents readfile is able to reach.
Tried some patterns, built myself a few but being not familiar to regex this is leading to nowhere.
Maybe the community can help me on this.
First I need a pattern to find paths inside a file (no problem with that, except not having the regex to strip the info out):
C:\Documents and Settings\Administrador\Meus documentos\Contas a receber.docx
D:\Documentos\Admin\Favoritos\Tarefas a cumprir.rtf
Depending on the scanned document, this can be found like:
(name of the computer)C:\ $ (3 non-characters or something like that) \\(name of the computer)\Documents and Settings\Administrador\Meus documentos\Contas a receber.docx
(name of the computer)D:\ $ (3 non-characters or something like that) \\(name of the computer)\Documentos\Admin\Favoritos\Tarefas a cumprir.rtf
I considered hard coding computer name and the $(chars) part, but in real world that failed.
That done, I need:
Files out of paths: Contas a receber.docx, Tarefas a cumprir.rtf
Paths out of pathnames: Documents and Settings\Administrador\Meus documentos\, Documentos\Admin\Favoritos\
Base drives: C:\, D:\
First parent folders: Meus documentos, Favoritos
If you prefer to deliver something like $fixedPattern, fine, I can replace the thing assuming the rest of the script will do the "reverse match", I mean: when I get something that works via regexreplace, it replaces matching pattern and not everything else that is not a match, which is expected but not desired if you know what I mean.
Suggestion: XY could support something like regexFind (regexInvert) - gets matches of regex (everything else other than matches of regEx), for us, regex-disabled people, then it would be easy to get a working pattern out there or build ourselves test patterns and see how that works immediately.
(Man I'm getting the hang out of scripting in XY, it's awesome!)
ah, a special thank you to Stefan whose help was invaluable in another thread regarding length of strings.
I'm trying to readfile find pathnames for files, strip files out of paths, paths out of pathnames, base drives only out of pathnames, first parent folders out of pathnames so I can get reports out of documents readfile is able to reach.
Tried some patterns, built myself a few but being not familiar to regex this is leading to nowhere.
Maybe the community can help me on this.
First I need a pattern to find paths inside a file (no problem with that, except not having the regex to strip the info out):
C:\Documents and Settings\Administrador\Meus documentos\Contas a receber.docx
D:\Documentos\Admin\Favoritos\Tarefas a cumprir.rtf
Depending on the scanned document, this can be found like:
(name of the computer)C:\ $ (3 non-characters or something like that) \\(name of the computer)\Documents and Settings\Administrador\Meus documentos\Contas a receber.docx
(name of the computer)D:\ $ (3 non-characters or something like that) \\(name of the computer)\Documentos\Admin\Favoritos\Tarefas a cumprir.rtf
I considered hard coding computer name and the $(chars) part, but in real world that failed.
That done, I need:
Files out of paths: Contas a receber.docx, Tarefas a cumprir.rtf
Paths out of pathnames: Documents and Settings\Administrador\Meus documentos\, Documentos\Admin\Favoritos\
Base drives: C:\, D:\
First parent folders: Meus documentos, Favoritos
If you prefer to deliver something like $fixedPattern, fine, I can replace the thing assuming the rest of the script will do the "reverse match", I mean: when I get something that works via regexreplace, it replaces matching pattern and not everything else that is not a match, which is expected but not desired if you know what I mean.
Suggestion: XY could support something like regexFind (regexInvert) - gets matches of regex (everything else other than matches of regEx), for us, regex-disabled people, then it would be easy to get a working pattern out there or build ourselves test patterns and see how that works immediately.
(Man I'm getting the hang out of scripting in XY, it's awesome!)
ah, a special thank you to Stefan whose help was invaluable in another thread regarding length of strings.