Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Merging tab delimited fields across two files  (Read 4086 times)

0 Members and 1 Guest are viewing this topic.

Ralphis

    Topic Starter


    Newbie

    • Experience: Experienced
    • OS: Windows 7
    Merging tab delimited fields across two files
    « on: February 05, 2020, 07:09:01 AM »
    Howdy,

    New member here and recently started working with some batch scripting (needs to be used on old XP machines sometimes). So far I've gotten a pretty good handle but I've run into a situation that I'm having a hard time understanding. I've read some other threads here and around the internet but am still stuck.

    Basically, I'm trying to use tokens to merge the information from two files with tab delimited info into one. Any help on how to get to where I need to go would be greatly appreciated. An example of my situation below:

    FileA.txt (SQL query output)

    HOSTNAME   MacAddress   Device   Type   LastUpdateDate
    ---------   ----------   ----   ----   --------------
    VR702386   00CE39CA6B7C   Example Unit 1   active   2019-11-22 17:12:34.600
    SJ180047   B8AEED7269F9   Example Unit 2   not active   2020-02-05 08:18:47.917
    UJ560066   003018CD200E   Example Unit 3   not active   2020-02-05 04:33:51.457

    FileB.txt (IP address ping output)

    VR702386   10.10.2.204

    Desired Output

    HOSTNAME   IP Address   MacAddress   Device   Type
    VR702386   10.10.2.204   00CE39CA6B7C   Example Unit 1   active
    SJ180047   Off Network   B8AEED7269F9   Example Unit 2   not active
    UJ560066   Off Network   003018CD200E   Example Unit 3   not active

    Really, the most important thing here is that I can include the IP address where applicable and that everything remains tab delimited. Header formatting isn't necessarily a big concern to me but is a bonus.

    If a unit cannot be pinged by hostname, it currently does not output anything to FileB.txt. Because of this, I would like to be able to indicate that any hostnames from FileA.txt without a corresponding IP address in FileB.txt cannot be reached ("Off Network" in my example output). Again, any help here would be awesome if this is even possible with a batch script. I'm stumped. Thanks!