web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Rename files based on ...
Power Automate
Answered

Rename files based on csv file

(0) ShareShare
ReportReport
Posted on by 10

Hi!

 

I have to rename over 500 files, but I don't want to rename them individually. (the file names have to be usernames instead of employee IDs) But I have a CSV file with all their usernames and employee IDs.

Is there a way in Power Automate to read each row that matches each file name (which is their employee ID) and then rename it to their username according to that CSV file? 

 

Any help at all would be greatly apricated! 

I have the same question (0)
  • Verified answer
    Henrik_M Profile Picture
    2,021 Super User 2024 Season 1 on at

    Yes!! And it should be very simple.

     

    Use a Read from CSV file action, which will produce a datatable.

    Add a For each loop to work on each row of this datatable.

    One action inside the loop might just be enough, the one called Rename file(s)

    Your Rename will use the product of the loop action, the %CurrentItem% variable.

    Since your %CurrentItem% is sliced from a datatable, it will be a datarow.

    The values in different columns of a datarow can be referred to either by the column header, which looks like %CurrentItem['Employee ID']% or the column index, which is simply %CurrentItem[0]% to select the first column's value.

    So your Rename action will rename %CurrentItem['Employee ID']% to %CurrentItem['Username']%

    You will probably need to include the folder path in the rename inputs.

     

    See if you can solve it from that description.

  • JasperV2 Profile Picture
    10 on at

    Yes!

    Your description worked perfectly! I just placed the folder path in the input before the variable, and BAM; renamed all the files. 

    Thank you! You were right, that sure was very simple 😆

  • tomh134 Profile Picture
    2 on at

    Hey, Just trying to implement this as have a few hundred files to rename based on specific criteria e.g. if files into category A then it will have prefix A / B to B etc. I've created a spreadsheet which handles this part. Then I've exported a CSV as multiple file options as wasn't sure which file format would be best 

    1) Full all columns: Old name / category / Prefix associated with category / Name minus old prefix / new name (which combines the prefix through an expression) 

    2) Only names: oldname / newname 

    3) prefix: old name/prefix 

     

    I've tried doing this in a few different ways including the method you've mentioned here that worked for Jasper. Unfortunately, I think I'm missing something. Hopefully, you can help me ? 

     

    Attached are Screenshots of the 2 methods I've tried 

    a) csv-files is the attempt at the method from your message - however, I'm getting an error related to data needing to be a list (image Flow2)

     

    Variable '$'''%CSVTable%%CurrentItem%'''' must be a list, datatable or datarow.

     

     

    b) rename-files-from-excel 

    tried following a youtube video for this one however, they went down a method of renaming the number sequentially rather than from a spreadsheet which is what I need. https://www.youtube.com/watch?v=vLne4POiUy0 

    (img Flow 1)

     

    Flow 2.png
    Flow 1.png
    flow 2 - b.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 796

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 538

Last 30 days Overall leaderboard