Rename Text Files Based On Content ("Line 4" - "Line 6".txt)
Posted: 21 Jul 2017 23:48
I have 250,000 text files (Stories of various names) in alphabetized folders.
What I would like to do is drop a batch file in to each of the folders, run it and have it rename all the text files in that folder. I have experimented with a few test batch files to no avail.
I would like to rename each text file based on the 4th line (Story Title) and the 6th line (Story's Author) of their respected text.....so the outputted file name would look like this:
Story Title - Story's Author.txt
Here is the line formatting for all of the files:
Line 1 (empty)
Line 2 (empty)
Line 3 (empty)
Line 4 < Story Title >
Line 5 empty
Line 6 < by Author's Name >
Line 7 (empty)
Line 8 (empty)
Line 9 (empty)
Line 10 Category: Various text Here
Line 11 Published: YYYY-MM-DD
Line 12 Updated: YYYY-MM-DD
Line 13 Packaged: YYYY-MM-DD HH:MM:SS
Line 14 Chapters: Numbers Here
Line 15 Publisher: website.com
Line 16 Story URL: https://www.website.com/s/xxxxxxxx
Line 17 Author URL: (empty)
Line 18 https://www.website.com/stories/memberp ... xxxxxxxxxx
Line 19 Summary: text here that sometimes extends down farther
From Line 18 down each file is different, but the story beginnings always start on Line 31. My thoughts are to maybe just delete lines 10 through 30 after the batch file reads Line 4 and 6 so it can rename them....or would it be better to use a second Batch file to delete lines 10 - 30 after the rename?
If I attempt to do this manually I think I will be doing this for the next 20 years.....HELP!
Many thanks for any help.
What I would like to do is drop a batch file in to each of the folders, run it and have it rename all the text files in that folder. I have experimented with a few test batch files to no avail.
I would like to rename each text file based on the 4th line (Story Title) and the 6th line (Story's Author) of their respected text.....so the outputted file name would look like this:
Story Title - Story's Author.txt
Here is the line formatting for all of the files:
Line 1 (empty)
Line 2 (empty)
Line 3 (empty)
Line 4 < Story Title >
Line 5 empty
Line 6 < by Author's Name >
Line 7 (empty)
Line 8 (empty)
Line 9 (empty)
Line 10 Category: Various text Here
Line 11 Published: YYYY-MM-DD
Line 12 Updated: YYYY-MM-DD
Line 13 Packaged: YYYY-MM-DD HH:MM:SS
Line 14 Chapters: Numbers Here
Line 15 Publisher: website.com
Line 16 Story URL: https://www.website.com/s/xxxxxxxx
Line 17 Author URL: (empty)
Line 18 https://www.website.com/stories/memberp ... xxxxxxxxxx
Line 19 Summary: text here that sometimes extends down farther
From Line 18 down each file is different, but the story beginnings always start on Line 31. My thoughts are to maybe just delete lines 10 through 30 after the batch file reads Line 4 and 6 so it can rename them....or would it be better to use a second Batch file to delete lines 10 - 30 after the rename?
If I attempt to do this manually I think I will be doing this for the next 20 years.....HELP!
Many thanks for any help.