Automatically bulk appending filenames to HTML <title>

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Automatically bulk appending filenames to HTML <title>

Postby monmajhi » Wed Sep 07, 2016 9:21 pm


I would like to automatically bulk/batch append the filenames of my html files to the titles of those files within the <title> tags inside the source code of those files. Is this possible with BRU?

I have converted a book in PDF format into html - using Acrobat Pro DC. I have the book divided into hundreds of html files now, each named like "part1.htm" or "part68.htm" etc. I am using the name/title of the book as the title for each of those html files within the <title> tags inside the source code of those files. But, I would like those titles within the <title></title> tags to reflect the corresponding "part number", i.e. the filenames of the files within which they are residing, by appending the filename at the end of the corresponding 'title'.

For example:
1. The name/title of the book is, say, "Archaeological Heritage of India".
2. One of the html filename is "part68.htm".
3. The title within the <title> tags in the source code of the file "part68.htm" is : <title>Archaeological Heritage of India</title>.

Now, I would like to turn the <title>Archaeological Heritage of India</title> in that file's html source-code into: <title>Archaeological Heritage of India_part68</title> (NOTE: minus the ".htm"!!). If it were only 1 or a few files, I could have done it manually easily. But, doing this manually in hundreds of files will be an excruciatingly laborious, painful and time-consuming task.

My question is: is it possible to automate this task with BRU? Can BRU copy all the html filenames (not the extensions) and append them to the corresponding source-code titles within the <title> tags in a batch/bulk renaming manner? If possible, then how??

Any quick help would be highly appreciated!
Posts: 1
Joined: Wed Sep 07, 2016 8:13 pm

Re: Automatically bulk appending filenames to HTML <title>

Postby therube » Thu Sep 08, 2016 12:48 am

Script it?

I've never used it, but maybe something like FART could help or be part of the solution (as might BRC)?
FART can seemingly work on either names or contents.
(Don't know if that's an 'or' or an 'and/or' ?)

So something like...

pass filename to grep, search for <title>.*</title>
strip the tags so that all you have is the title name
assign that name to a variable %i
rename the file contents & or file name based on that ... ?
Posts: 390
Joined: Mon Jan 18, 2016 6:23 pm

Return to BRU Support