Computing.Net > Forums > Disk Operating System > Create files based on the values of

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Create files based on the values of

Reply to Message Icon

Name: raghav525
Date: March 12, 2009 at 14:04:10 Pacific
OS: Windows XP
Subcategory: General
Comment:

Hello,
i would like to write a DOS Batch script to create a multiple files based on the values from a single file mainfile.txt (For instance, mainfile.txt has 5 values as
A200001
A200002
B200101
C200101
C200201
I need a dos batch script to create five files with below names and it values are also same
File name - Its value
A200001.txt - A200001
A200002.txt - A200002
B200101.txt - B200101
C200101.txt - C200101
C200201.txt - C200201

mainfile.txt may have any values and may have any no. values. Could some one please assist me on this?

Thanks for your help



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 12, 2009 at 16:49:05 Pacific
Reply:

What is a file's "value"?


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: raghav525
Date: March 13, 2009 at 08:19:11 Pacific
Reply:

Values --- I mean, the content of the file; File (mainfile.txt) has records as A200001
A200002
B200101
C200101
C200201
and would like to create different files based on the content of mainfile.txt


0

Response Number 3
Name: Valerie (by Garibaldi)
Date: March 13, 2009 at 17:25:35 Pacific
Reply:

Untested...

@echo off
cls

for /f  %%1 in (mainfile.txt) do (
       echo %%1>%%1.txt
)
exit/b


0

Response Number 4
Name: raghav525
Date: March 16, 2009 at 13:27:49 Pacific
Reply:

Thanks, It worked. But, actual requirement is as below... I am able to do this on Unix with the help of other person. But is someting posible in windows batch???

Here is the detail example: I have a textfile and four static parameter files (having ‘?’). mainfile.txt has below records (this count may be more than 50)
A200001
A200101
B200001
B200002
C200001
D200101
D200102
D200201

And 4 static parameter files corresponding to records in mainfile.txt, started with A,B,C,D
1.audit_paramter.prm
[PQRS.temp_info]
$$Source_file_audit=?
$$Source_file_audit_dir = \\dal1mspcx55\cogent$\productionqc\?\?

2.borrower_paramter.prm
[PQRS.temp_info]
$$Source_file_borrower =?
$$Source_file_borrower_dir = \\dal1mspcx55\cogent$\productionqc\?\?

3.carriage_paramter.prm
[PQRS.temp_info]
$$Source_file_carriage =?
$$Source_file_carriage_dir = \\dal1mspcx55\cogent$\productionqc\?\?

4.document_paramter.prm
[PQRS.temp_info]
$$Source_file_document =?
$$Source_file_document_dir = \\dal1mspcx55\cogent$\productionqc\?\?


Now I would like to create different parameter files based on the records from mainfile.txt and using static parameter files

If records starts with A, it should create audit_paramter_*.prm such as
audit_paramter_A200001.prm
[PQRS.temp_info]
$$Source_file_audit=A200001
$$Source_file_audit_dir = \\dal1mspcx55\cogent$\productionqc\2000\A200001

audit_paramter_A200101.prm
[PQRS.temp_info]
$$Source_file_audit=A200101
$$Source_file_audit_dir = \\dal1mspcx55\cogent$\productionqc\2001\A200101

If records starts with b, it should create borrower_paramter_*.prm and so on.. like 8 different parameter files??? Would this possible do with sed / scripting??? Can someone please assist?

I can replace ‘?’ with other symbols to differentiate two different values or we can create new paramter values with our using exsiting (which i did in unix)

Thanks in advance


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Heart monitor how to execute exe in cal...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Create files based on the values of

Trying to purge files based on Date www.computing.net/answers/dos/trying-to-purge-files-based-on-date/13804.html

Removing files based on creation date www.computing.net/answers/dos/removing-files-based-on-creation-date/10389.html

String Mainupation www.computing.net/answers/dos/string-mainupation/11503.html