You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Data Factory中多源文件夹文件迁移至单输出文件夹并保留源文件名的实现方案问询

Migrate Excel Files to Target Folder with Original Filenames (No Source Hierarchy)

Got it, let's fix this properly—your two initial attempts were close but missed the key settings to balance flattening the folder structure and keeping your original filenames. Here's the step-by-step solution:

Step 1: Set Up the Source Dataset

First, configure your source dataset to capture all Excel files across those nested subfolders:

  • Point your source dataset to your storage (Azure Blob, ADLS Gen2, etc.)
  • Use a wildcard file path to grab every .xlsx file under the Source/ directory, no matter how deep it is:
    Source/**/*.xlsx
    
    The ** wildcard matches any number of subfolders, so it'll pick up all your files from 2021/01/01/, 2021/03/02/, and so on.
  • You can use either the Excel file format (if you need to interact with the file content) or Binary (for a straight copy-paste of the file)—both work here.

Step 2: Configure the Sink & Copy Activity

Now set up the target to drop all files flat in the Output/ folder while keeping their original names:

  • Create a sink dataset pointing directly to the Output/ folder in your target storage.
  • Open your Copy Activity, go to the Sink tab:
    • Under File name behavior, select Preserve filename—this ensures each copied file keeps its exact original name from the source.
    • Make sure Preserve hierarchy is unchecked—this stops the tool from replicating the 2021/01/01/ folder structure in your Output folder.

Optional: Handle Duplicate Filenames

If you have multiple files with the same name in different source folders, the default setup will overwrite the file in Output. To avoid this:

  • Choose Preserve filename with suffix in the File name behavior—this adds a numeric suffix (like report.xlsx, report-1.xlsx) to duplicate files.
  • Or, use a dynamic expression to append part of the source path to the filename (e.g., @concat(split(item().name, '/')[2], '_', item().name) to add the year/month) if you need to track where duplicates came from.

Why Your First Two Tries Didn't Work

  • Method 1 (Binary format, default settings): Copy Activity preserves the source folder hierarchy by default, which is why you ended up with the full 2021/01/01/ structure in Output.
  • Method 2 (Flatten Hierarchy): This mode uses random GUIDs for filenames to automatically avoid conflicts, which overrides your original file names—exactly what you wanted to avoid.

内容的提问来源于stack exchange,提问作者amikm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 14:12:32