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 a bunch files t...
Power Automate
Unanswered

Rename a bunch files to a specific name

(0) ShareShare
ReportReport
Posted on by Super User 2024 Season 1

Hello,

I have several clients that sent me email with attachment, but the clients send the attachment with a different name.  So when I download the attachment I rename the file based on the company name so I know which company the attached is for?  On PAD script I go to my exchange server and download all the attached files from all the companies.  The challenge is I don't know how to rename each file based on the company name.  For example, let say someone I have several clients and one of the name jeanrobert@apllogistics.com and his attachment name Aging 01.31.23.xlsx and another client smithjohn@besttranportation.com and her attachment name Monthly Report January 01-31-23.xls.

My task is to rename the first attachment as APL Logistics.xlsx and rename the second attachment as Best Transportation.xls (based on the company email address and so on...)  That way I know which file is from the company. How I can achieve this task?

Thank you!

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    I am new to this post and I saw 6 people already views my issue.  Where to go to see the response?

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    After getting the email and downloading attachments:

     

    For Each %CurrentItem% in %RetrievedEmails%

        Parse Text %CurrentItem.From% to find "@" as %Position% 'note:  this is the wrong format; when you set it up, use the dropdowns...it's something like %CurrentItem['From']; not sure why...to and from email properties are the only ones like this.  Parse text gives you the position of the text you are looking to find.

        Parse Text %CurrentItem.From% to find ".com" as %Position2%

        Get SubText %CurrentItem.From% from %Position + 1% to %Position2 - 1% 'I may be wrong on Position 2 - 1, just change it to -2 or just %Position2%....little trial and error.

        Rename Files %CurrentItem.Attachment% to 'whatever format you want to name it to using the domain you've extracted

        Move Files %RenamedFiles% to whatever folder you want so it's not in your downloads folder.

    End (For Each)

     

    This will loop through all emails, rename attachments based on the domain of the From email, and move it to the folder of your preference.

     

    Good luck!

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    Hi Michael,

    Thank you so much for your reply.  I am using Power Automate Desktop Script.  Is there something like that or this is different language/script? I am browsing to the script and I don't actions like that.  Sorry I am also new to PAD and I am try to see if I can automate some repeat job.

    Thanks again and looking forward for your reply.

     

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    I don't know what Power Automate Desktop Script is.  Power Automate Desktop is a drag-n-drop, low code software you can install on a local machine (or use unattended if you pay for a premium service).

     

    So, when I say "For Each", it is literally the "For Each" action that you drag from the left side of your screen to the flow, and then fill out the parameters.

     

    MichaelAnnis_0-1677708860794.png

     

    MichaelAnnis_1-1677708898285.png

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    Thank you very much.  I am still having hard time to follow your direction.  As I mentioned, I am new to this and I have no clue what I am doing.  Is there a way you can put something together for from start to finish so I can see how you did it?  This is what I have bu looking your description, but they all wrong. Thanks again!

     

    TTC_0-1677733459144.png

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    Is there anyone else beside Michael can help me archive this task?

    Thanks!

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    I am so desperate to get this done.  Please, please, I am begging someone to help me with this.  I am getting this message, and I don't know what I do wrong.

    TTC_0-1677817117304.png

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    I also have multiple attachments on one email.  I need to save each file as a unique name.  For example, if I have jeanrobert@aplllogistics.com send me three attachments, I need to save each file as Five Below_1.xlsx, Five Below_2.xlsx, and Five Below_3.xlsx and so on... 

    I have sent multiple posts but only one person reply.  If no one won't comment just tell me, and I won't post anything anymore.

    I see a lot people online but everyone ignore my post.  I just need a solution for my task.

    Thank you!

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    I have another challenge where I cannot add more than one email address from the 'From' field.  I have different clients send email attachment within the same company.  I've tried everything so far no luck.  Anyone have any idea on how to do this?  Thank you!

    TTC_0-1677876227902.png

     

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    Hi @TTC 

    Create a new topic for the new issue, that helps others to find solutions to their problems.

    In the new topic explain what exact issues with setting up the "from" you have.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 426

#2
11manish Profile Picture

11manish 349 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard