Renaming a list of files

Salma Ben Saaid 11 Reputation points
2021-09-28T11:48:23.127+00:00

I have a list of folders each containing a liste of files, I am using a get metadata and copy activity to copy them into azure blob storage. I am looking for a way to rename my files dynamically , my current files have the pattern nameofFile_***.txt and I would like to rename it nameofFile.txt.

Thank you

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,628 questions
{count} vote

1 answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 37,971 Reputation points Microsoft Employee
    2021-09-29T06:52:32.5+00:00

    Hi @Anonymous ,

    Thank you for posting your query on Microsoft Q&A Platform.

    You need to have a parameter for your file name in Sink dataset and pass file name value dynamically to that parameter.

    Below are detailed steps listed.

    Step1: Using GetMetaData Activity, I am getting file name.

    136193-image.png

    Step2: Inside sink dataset have a parameter for file name and Pass your sink file name dynamically. Use expression language to get desired file name dynamically.
    Here, I am using a variable and using below expression to dynamically compose my sink file name
    expression used: @concat(split(activity('Get Metadata1').output.itemName,'_')[0],'.',split(activity('Get Metadata1').output.itemName,'.')[1])

    136201-image.png

    Hope this will help. Please let us know if any further queries. Thank you.

    ---------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments