none
How to do filename manipulations in VB RRS feed

  • General discussion

  • I am completely newbie to VB Scripting. Can someone help me with a requirement where I have list of files in a directory, I want to manipulate the filenames in required format as mentioned below.

    < Filenames present in directory > AAAL_555A_ORANGE_F190404_D190408.TXT.freshfruits_20190422-115617 AAAL_555A_MANGO_F190404_D190408.TXT.freshfruits_20190422-120939 AAAL_555B_APPLE_F190404_D190408.TXT.freshfruits_20190422-121449 AAAL_555B_ORANGE_F190404_D190408.TXT.freshfruits_20190422-115617 AAAL_555B_Orange_F190404_D190408.TXT.freshfruits_20180422-115617 <After modification > If 2nd string 555A and 3rd string is ORANGE or 2nd string 555A and 3rd string is Orange the filename should be BB_Orange_555a_date +'%Y%m%d'.txt If 2nd string 555B and 3rd string is ORANGE or 2nd string 555A and 3rd string is Orange the filename should be BB_Orange_555b_date +'%Y%m%d'.txt If 2nd string 555B and 3rd string is APPLE or 2nd string 555A and 3rd string is Apple the filename should be BB_Apple_555b_date +'%Y%m%d'.txt If 2nd string 555A and 3rd string is MANGO or 2nd string 555A and 3rd string is Mango the filename should be BB_Mango_555a_date +'%Y%m%d'.txt

    Set ObjFSO = CreateObject("Scripting.FileSystemObject")
    objStartFolder = "C:\test"
    Set objfolder = ObjFSO.getfolder(objStartFolder)
    Set colfiles = objfolder.Files
    For Each objFile In colfiles
    'MsgBox objFile.Name
    temparr1 = Split(objFile.Name, "_")
    'MsgBox temparr1(1)

    next

    • Changed type Bill_Stewart Thursday, September 5, 2019 9:24 PM
    • Moved by Bill_Stewart Thursday, September 5, 2019 9:24 PM This is not "design solution for me" forum
    Wednesday, May 8, 2019 8:51 AM

All replies