Simon336697
asked on
Creating a global master file.
Hi everybody,
I hope you are well and can help.
I have a top folder. Let's call is "Master".
Underneath this folder, I have many subfolders, of unknown number, but all will contain 3 files, with similar naming convention.
So, the folder structure could look like this..
Parent Child
Folder Folder 3 files of similar naming convention
Master
|_______ ad
|_________1of3_workings_ad .txt
|_________2of3_sorted_ad.t xt
|_________3of3_master_ad.t xt
|_______ batchfile
|_________1of3_workings_ba tchfile.tx t
|_________2of3_sorted_batc hfile.txt
|_________3of3_master_batc hfile.txt
|_______ sccm
|_________1of3_workings_sc cm.txt
|_________2of3_sorted_sccm .txt
|_________3of3_master_sccm .txt
|_______ vmware
|_________1of3_workings_vm ware.txt
|_________2of3_sorted_vmwa re.txt
|_________3of3_master_vmwa re.txt
As you can see, the naming conventions for the 3 files are:
1of3_workings_*.txt
2of3_sorted_*.txt
3of3_master_*.txt
where "*" is the same name as the folder name given for the child folder these files reside in.
========================== ========== ========== ========== ========== =========
What I want to do is the following:
I want to create a script, that will create a text file that contains the contents of every 3of3_master_*.txt in the above folder structure.
So, for example, in the above scenario, this is how it would look....
script.cmd
1.Create a text file called 'GLOBAL-MASTER.txt'.
2.Read every subfolder of the top folder 'Master', looking for a file called '3of3_master_*.txt'
3.For each file 3of3_master_*.txt found, read its contents and copy into the 'GLOBAL-MASTER.txt' file created in step 1.
4.Leave a line or 2 blank space between each '3of3_master_*.txt' in the new GLOBAL-MASTER.txt file.
Here for example, are the contents of each file targetted...
-------------------------- ---------- ---------- --- 3of3_master_ad.txt
-------------------------- ---------- -------
Master: ad
-------------------------- ---------- -------
item1,item2,item3;
-------------------------- ---------- ---------- --- 3of3_master_batchfile.txt
-------------------------- ---------- -------
Master: batchfile
-------------------------- ---------- -------
batch,token;
-------------------------- ---------- ---------- --- 3of3_master_sccm.txt
-------------------------- ---------- -------
Master: sccm
-------------------------- ---------- -------
deployment type;
-------------------------- ---------- ---------- --- 3of3_master_vmware.txt
-------------------------- ---------- -------
Master: vmware
-------------------------- ---------- -------
esx,vsphere;
The output by running the script will be like below.
========================== ========== ========== ========== ========== === GLOBAL-MASTER.txt
-------------------------- ---------- -------
Master: ad
-------------------------- ---------- -------
item1,item2,item3;
-------------------------- ---------- -------
Master: batchfile
-------------------------- ---------- -------
batch,token;
-------------------------- ---------- -------
Master: sccm
-------------------------- ---------- -------
deployment type;
-------------------------- ---------- -------
Master: batchfile
-------------------------- ---------- -------
esx,vsphere;
So, you can see, that the script will create a text file called 'GLOBAL-MASTER.txt, which will contain the contents of all 3of3_master_*.txt in the above folder structure.
Any help greatly appreciated.
I hope you are well and can help.
I have a top folder. Let's call is "Master".
Underneath this folder, I have many subfolders, of unknown number, but all will contain 3 files, with similar naming convention.
So, the folder structure could look like this..
Parent Child
Folder Folder 3 files of similar naming convention
Master
|_______ ad
|_________1of3_workings_ad
|_________2of3_sorted_ad.t
|_________3of3_master_ad.t
|_______ batchfile
|_________1of3_workings_ba
|_________2of3_sorted_batc
|_________3of3_master_batc
|_______ sccm
|_________1of3_workings_sc
|_________2of3_sorted_sccm
|_________3of3_master_sccm
|_______ vmware
|_________1of3_workings_vm
|_________2of3_sorted_vmwa
|_________3of3_master_vmwa
As you can see, the naming conventions for the 3 files are:
1of3_workings_*.txt
2of3_sorted_*.txt
3of3_master_*.txt
where "*" is the same name as the folder name given for the child folder these files reside in.
==========================
What I want to do is the following:
I want to create a script, that will create a text file that contains the contents of every 3of3_master_*.txt in the above folder structure.
So, for example, in the above scenario, this is how it would look....
script.cmd
1.Create a text file called 'GLOBAL-MASTER.txt'.
2.Read every subfolder of the top folder 'Master', looking for a file called '3of3_master_*.txt'
3.For each file 3of3_master_*.txt found, read its contents and copy into the 'GLOBAL-MASTER.txt' file created in step 1.
4.Leave a line or 2 blank space between each '3of3_master_*.txt' in the new GLOBAL-MASTER.txt file.
Here for example, are the contents of each file targetted...
--------------------------
--------------------------
Master: ad
--------------------------
item1,item2,item3;
--------------------------
--------------------------
Master: batchfile
--------------------------
batch,token;
--------------------------
--------------------------
Master: sccm
--------------------------
deployment type;
--------------------------
--------------------------
Master: vmware
--------------------------
esx,vsphere;
The output by running the script will be like below.
==========================
--------------------------
Master: ad
--------------------------
item1,item2,item3;
--------------------------
Master: batchfile
--------------------------
batch,token;
--------------------------
Master: sccm
--------------------------
deployment type;
--------------------------
Master: batchfile
--------------------------
esx,vsphere;
So, you can see, that the script will create a text file called 'GLOBAL-MASTER.txt, which will contain the contents of all 3of3_master_*.txt in the above folder structure.
Any help greatly appreciated.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thx so much and sorry for the delay. happy christmas to all.
ASKER
Thanks so much for that.
That looks unix like.
Im more of a wintel person.