Hi, may I ask how can I rename 100 files with an excel mapping table? for example my original file names are GA01_310823.txt, GA02_310823.txt, GA03_310823.txt……until GA100_310823.txt
I have an excel mapping table which has 2 columns which is ReportCode and ReportName, the ReportCode is GA01,GA02,GA03……until GA100. ReportName is DIVIDEND REPORT, INTEREST REPORT, INCOME REPORT…… until PENDING REPORT.
How do I rename them for example GA01_310823.txt to be renamed to DIVIDEND REPORT? Many thanks in advance!
Hi
Hope the below steps would help you resolve this
- Use a assign activity like this
arr_filepaths = Directory.GetFiles(“your folder path”)
Where arr_filepaths is a variable of type array of strings
-
Now use a for each activity and pass array variable as input
Change the type argument as string
-
Inside the loop use a LOOKUP DATATABLE activity where pass these properties
Find this value / lookup value = Split(item.ToString, “_”)
Lookup datatable = dt
(dt is the datatble read from excel)
In the column name = ReportCode
Output / return value from column = str_newname
- Now use a rename file activity where in file mention the value as item.ToString and new name as str_newname
Hope this helps
Cheers @poh_kuen_goh
Hi @poh_kuen_goh ,
It’s same my process
my input folder
file
output
file full code
Multi_rename.zip (10.4 KB)
regards,
Thanks Albert!
Some how i’m not able to open the zipped file. Not sure if you could screenshot the process? Thanks a lot.
Morning @poh_kuen_goh ,
My step
1.read file excel get data Name
2.get all file in folder, where have list text file need rename
3. loop for each row data table Name inside for each file in folder
compare file name with row Code
rename file with name is rowName.toString
regards,