skip to Main Content

How can I copy files from an input container to an output container in Azure blob storage, and sort them into three different folders based on their file size, with files less than 1KB going to the 1KB folder, files between 1KB to 2KB going to the 2KB folder, and files larger than 2KB going to the more than 2KB_More folder?

Any one can help on this

2

Answers


  1. Please use the below logical flow :

    1. use get meta data activity to get child items list within the input container
    2. use for each activity with child items list as input
    3. within for each, use get meta data activity to get file size
    4. use set variable activity to set the destination path based on file size
    5. use copy activity with dynamic sink
      sample for dynamic : Azure Data Factory Dynamic Content Filename Syntax
    Login or Signup to reply.
  2. Adding to @Nandan‘s answer, The 4th step in the above process can be done like below.

    After getting file size from second Get meta data activity, first convert the bytes to KB with the below expression.

    @string(div(activity('Get Metadata2').output.size,1024))
    

    enter image description here

    Then use if expression in another variable set the folder names like below.

    @if(equals(int(variables('size')),0),'1KB',if(equals(int(variables('size')),1),'2KB','2KB_more'))
    

    enter image description here

    Use this name in the sink dataset foldername.
    My Result:

    enter image description here

    NOTE: If you are copying different types of files, it’s better to use a binary datasets for this.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search