Batch program required to edit text files in folder

January 26, 2012 at 08:48:38
Specs: Windows XP

Good afternoon Ladies and Gentlemen,

I am requesting your help with the following for an XP pc:

I have a folder on my "C" drive called Test.
In this folder, I have a number of text files. eg. “Text.txt”, “Test.txt” and “Try.txt”.
Note that there can be any amount of text files in this folder.

I need to scan through each text file in this folder and copy a string of text within the file and then use this string to rename the file.

For example “Text.txt”, should be scanned through and the string to copy is “This is a test1”. NB That this string is located at a specific point in the text file and the end of it can be determined by “2 spaces”.
When this string is copied, then it should be used to rename the file, hence “Text.txt” should be renamed to “This is a test1.txt”.

See example below.

Contents of Text.txt are as follows:

Test This is a test-------

Testing: This is a test1


A scan of the file is done and “This is a test1” is copied.
This is then used to rename the file from “Text.txt” to “This is a test1.txt”.
We then complete this task for all files in the “Test” folder until all are renamed.

I hope I have explained it properly for you.

Thanks in advance for all your help. :)

See More: Batch program required to edit text files in folder

Report •

January 26, 2012 at 13:32:34
Do all .txt files contain just two lines as shown for Test.txt?

Please come back & tell us if your problem is resolved.

Report •

January 26, 2012 at 13:48:02
Hi Wahine,

No they do not. They can have up to about 100 lines, but the string is at a fixed location ( Line 6, Col 52 ) that I want copied and the end of the string can be determined whenever it encounters (2 spaces) after reading the string.

Hope this helps,

Thanks for asking.


Report •

January 26, 2012 at 13:58:49
Please post a couple of examples of line 6.

Please come back & tell us if your problem is resolved.

Report •

Related Solutions

January 27, 2012 at 07:46:31
Hi Wahine,

The string I need copying below is "THE TEST COMPANY & NATION LTD". The below example then ends when 2 spaces are encountered. Taking note that there are special characters sometimes and also the text being copied can be any length.

TOWN TIME: 17:21:45
Test Payment Company Identification Number : 7 TTS
Test Payment Company Name................. : THE TEST COMPANY & NATION LTD
Test Payment Company Address.............. : P.O BOX 5367


Report •

January 28, 2012 at 12:06:40
Just to let you know your query has not been forgotten.

Taking note that there are special characters sometimes Your having advised of this puts a more complicated slant on any response. Some characters have special meaning in the Command Processor and therefore cannot be used in filenames so any renaming which includes one (or more) of these characters will fail. Such characters must be replaced with an acceptable alternative, unfortunately the simple well known method of doing this will not work with some special meaning characters.

A young friend of mine is seeking an answer on another forum and we will get back to you as soon as practicable.


Please come back & tell us if your problem is resolved.

Report •

January 30, 2012 at 02:45:51
Hi Wahine,

Let me thank you in advance for assisting. Well it help to know that the only special characters are " . " , " & ", " ' " and " - ". Can this help that there are only 4 special characters?

Have a great day,

Report •

March 29, 2012 at 10:25:51
Hi Wahine,

How are you doing?
Any update on my query.


Report •

Ask Question