Member 14132591 Ответов: 0

Как добавить текст за определенным ключевым словом в filename в ruby?


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

0 Ответов