Hello everyone,
Posting here after a long time, been away from unix world lately and it seems I have forgotten my shell scripting completely. I have a requirement where a csv file contains following columns:
Full Registration VIN Stock ID Mileage InternalTrim Description Warranty FranchiseApproved RegistrationDate Featured New Vehicle Type Used stock images
2653BA WDD1173461N6437866 2725 19434 Leather trim Y Y 19/09/2018 N N CAR
8874MS WDD1173461N6494217 2745 15452 Leather trim Y Y 19/09/2018 N N CAR
This csv file will be sent to a hosting service provider who is hosting our used car website. Every used car has some images and names of those images need to be populated in the last column of this csv file but there is one challenge, image files are stored (in the same directory) as Stock ID_001, Stock ID_002 and so on. From this csv file example, image files will be 002795_001, 002795_002, 002795_003 and same for rest of the vehicles. We don't know in advance how many image files will be there for one stock ID. We need to rename these image files as VIN NO_1, VIN_NO_2 and so on. Therefore for this example, image file names will become WDD1173461N6437866_1, WDD1173461N6437866_2, WDD1173461N6437866_3 because stock ID 2795 has VIN number WDD1173461N6437866.
Once the image files are renamed then we need to populate these names in the last column of above csv file. so the last column of above csv file will become (for the first record). Please note we have to ignore the header and image file names to be populated from 2nd record onwards (after renaming) as explained above.
Full Registration VIN Stock ID Mileage InternalTrim Description Warranty FranchiseApproved RegistrationDate Featured New Vehicle Type Used stock images
2653BA WDD1173461N6437866 2725 19434 Leather trim Y Y 19/09/2018 N N CAR WDD1173461N6437866_1,WDD1173461N6437866_2,WDD1173461N6437866_3
Can you please help me with this challenge?
Regards,
Tayyab