#1 2009-04-17 18:30

Brig
Member
Registered: 2009-04-17
Posts: 2

Get text from within files for renaming?

Howdy:

First, thanks for this great program--it really works very well. It's easy to use too. Except now I've run into something difficult (for me):

I've got about 500 SGML files (plain text with <tags> in them) that currently have unhelpful numbers for names--for example, 1414429908-00001.sgm. I would like to rename each file with the contents of its <title> tag--that is, all the files contain (near the top) a line like this:

<title>The title of the file</title>

So renaming 1414429908-00001.sgm using its <title> tag info would make it Abnormal involuntary movement scale.sgm (ideally, the same operation would also lowercase all the letters and change spaces to underscores; but that could be a separate step).

From what I've seen in the forum, it looks like I'll need a Pascal script for this--but my expertise stops at basic regular expressions. I'd really appreciate any help you can offer.

Many thanks,
Brig

Last edited by Brig (2009-04-17 19:39)

Offline

#2 2009-04-17 20:39

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Re: Get text from within files for renaming?

Howdy Brig,

You are right, normally you would need PascalScript for this kind of operations. But in your case you can use little trick called HTML_Title meta tag. This tag will extract content of <title>*</title> tag within HTML file, so the only thing you need to do is to make ReNamer think your SGM files are HTML files.

Your renaming operation needs to be done in 2 steps:
1) Temporarily change *.SGM extension to *.HTML, rename;
2) Add :HTML_Title: tag from within Insert rule, and change back to original *.SGM extension, rename.

Offline

#3 2009-04-17 21:06

Brig
Member
Registered: 2009-04-17
Posts: 2

Re: Get text from within files for renaming?

Wow! Fabulous! That is just great.

Thanks for your help and, again, for this amazing program.

Best,
Brig

Offline

#4 2013-11-20 09:32

carib909
Member
Registered: 2013-11-20
Posts: 4

Re: Get text from within files for renaming?

den4b wrote:

Howdy Brig,

You are right, normally you would need PascalScript for this kind of operations. But in your case you can use little trick called HTML_Title meta tag. This tag will extract content of <title>*</title> tag within HTML file, so the only thing you need to do is to make ReNamer think your SGM files are HTML files.

Your renaming operation needs to be done in 2 steps:
1) Temporarily change *.SGM extension to *.HTML, rename;
2) Add :HTML_Title: tag from within Insert rule, and change back to original *.SGM extension, rename.


I tried that with wma files. When I changed the extensions to HTML, the files lost all the meta data, or at least it no longer shows under properties. When I tried the "insert" operation, nothing was renamed with the "Title" value.

Offline

#5 2013-11-20 11:28

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Re: Get text from within files for renaming?

carib909 wrote:

I tried that with wma files. When I changed the extensions to HTML, the files lost all the meta data, or at least it no longer shows under properties. When I tried the "insert" operation, nothing was renamed with the "Title" value.

WMA files are not like HTML, they store binary content while HTML has plain text tags which can be easily extracted. You can see the difference easily when you open those files with a text editor. So that trick will not work with WMA files.

For WMA files you should use :WMA_Title: meta tag from the Insert rule. For more info check out Meta Tags article on the Wiki.

Offline

Board footer

Powered by FluxBB