Click here to Skip to main content
15,891,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to add a text to a filename in Ruby in order for a job to know which files to be picked up in the directory.

For example in directory C:\Users\Scripts, I may have files named:

2A_Apple_VC_20180101.txt
2A_Apple_VC_20180201.txt
2A_Apple_VC_20180301.txt
etc.

How can I insert the phrase "Vendor" right after "2A_" for all the filenames in that directory that starts with 2A_ permanently changing the filenames to:

2A_Vendor_Apple_VC_20180101.txt
2A_Vendor_Apple_VC_20180201.txt
2A_Vendor_Apple_VC_20180301.txt

Your help is greatly appreciated.

Thank you, Julie

What I have tried:

Not sure where to start since I'm new to Ruby
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900