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

Power Automate保存Outlook附件时如何去除文件名后缀的日期串

解决Power Automate中Outlook附件重命名保存到SharePoint的问题

核心需求实现:提取原始文件名

在SharePoint的Create File动作的FileName字段中,使用以下Power Automate表达式生成目标文件名(替换items('Apply_to_each')?['Name']为你流程中实际的附件名称动态内容):

场景1:文件名仅含1个下划线(如OrigamiUserList_2023-03-09-0103.xlsx)

concat(first(split(items('Apply_to_each')?['Name'], '_')), '.', last(split(items('Apply_to_each')?['Name'], '.')))

表达式拆解:

  • split(..., '_'):将文件名按下划线拆分为数组(示例结果:["OrigamiUserList", "2023-03-09-0103.xlsx"])
  • first(...):提取数组第一个元素(即不带时间戳的主文件名:OrigamiUserList)
  • split(..., '.'):将原文件名按小数点拆分为数组(示例结果:["OrigamiUserList_2023-03-09-0103", "xlsx"])
  • last(...):提取数组最后一个元素(即文件扩展名:xlsx)
  • concat(...):将主文件名与扩展名拼接为最终文件名:OrigamiUserList.xlsx

场景2:文件名含多个下划线(如Origami_User_List_2023-03-09.xlsx)

如果主文件名本身包含下划线,需要提取最后一个下划线前的所有内容,使用以下表达式:

concat(substring(items('Apply_to_each')?['Name'], 0, lastIndexOf(items('Apply_to_each')?['Name'], '_')), '.', last(split(items('Apply_to_each')?['Name'], '.')))

表达式拆解:

  • lastIndexOf(..., '_'):定位最后一个下划线在文件名中的位置
  • substring(...):提取从文件名开头到该位置的内容(示例结果:Origami_User_List)
  • 后续逻辑同场景1,拼接扩展名得到最终文件名

解决空白文件问题

直接输入固定文件名导致上传空白文件,是因为Content字段未绑定附件的实际内容:

  • 在Create File动作的Content字段中,必须选择Outlook附件对应的Attachment Content动态值(而非空值或其他内容)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 18:27:14