Extract substring from filename

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

Post Reply
X-Ray
Posts: 2
Joined: Wed Nov 06, 2013 9:19 am

Extract substring from filename

Post by X-Ray »

Hi,

is it possible to extract a substring (defined by regex or length) from the filename to "plot" it as text into the image?
I have files with names like
"1000x some words and numbers.jgp" or "250x some other words.jpg"
and want to extract the beginning number "1000" respectively "250" (the subsequent "x" may be included)

thanks in advance :wink:
User avatar
xnview
Author of XnView
Posts: 43357
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Extract substring from filename

Post by xnview »

no sorry
Pierre.
X-Ray
Posts: 2
Joined: Wed Nov 06, 2013 9:19 am

Re: Extract substring from filename

Post by X-Ray »

would be a nice feature :wink:
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Extract substring from filename

Post by cday »

X-Ray wrote: ... is it possible to extract a substring (defined by regex or length) from the filename to "plot" it as text into the image?
It might be possible to do it using a batch file that first calls a command line file renaming utility and then calls NConvert, if the required substring can be extracted to a variable, which is then written to the image using NConvert's -text syntax.

One command line batch renaming utility:

http://www.bulkrenameutility.co.uk/Download.php -- Scroll down for the command line version.

Note that I haven't used it myself, and only suspect that it might be able to copy a string from a filename to a variable.
Post Reply