Rename multiple files

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!

@poh_kuen_goh

Welcome to the community

  1. For each file in Folder
  2. Inside loop use look up datatable and lookup for the currentFile.Name which is the current file name
  3. Use Rename file activity and pass the currentFile.FullName and rename to be return of lookup tbale activity

cheers

Hi

Hope the below steps would help you resolve this

  1. Use a assign activity like this

arr_filepaths = Directory.GetFiles(“your folder path”)

Where arr_filepaths is a variable of type array of strings

  1. Now use a for each activity and pass array variable as input
    Change the type argument as string

  2. 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

  1. 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
image
file
image
output
image

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,