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 Automate
Answered

Python Scrip on PA

(0) ShareShare
ReportReport
Posted on by 25

Hello everyone, i have a problem, when i try to run a script made in python i cant.

 

The following script is:

 

import shutil
from datetime import date
path = 'path/to/new/destination/for/file'
today = date.today()
today = today.strftime("%d_%m_%Y")
file_name = f"{path}{today}.txt"
shutil.move("path/to/current/file.foo", file_name)

 

In this case the two path are confidencial information. I try to put System.RunPythonScript before all the code but nothing happens.

 

The error is the following: Syntax error.

 

Can anybody help me?

 

Thank you !

  • Verified answer
    miketran13 Profile Picture
    720 on at

    Hi,

     

    I don' know Python but there is one thing that is conflicted with PAD "%%", try to avoid using this, because when using this, PAD will recognize it as their syntax and it will throw error since it is not followed their format.

     

    miketran13_0-1614747006778.png

    Thanks and hope it can help you. 

    Mike

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

    Did I answer your question? Please consider to Mark my post as a solution! to guide others

  • Godlees Profile Picture
    25 on at

    Hello mike,

     

    Thanks for answer me.

     

    In this case, i have to find one alternative to &.

     

    But i understand the error, PAD is taking as a variable.

     

    Regards,

     

    Santi

  • matow_MSFT Profile Picture
    Microsoft Employee on at

    Hi @Godlees, the % sign can be escaped with a backslash ahead of it (ex. \% instead of %). 

     

    As a fallback to the Python action if the script doesn't change, the CMD session actions (documentation) could also be used to trigger a Python script on the command prompt. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi,

    I faced the same issue & found below workaround solution, instead of using string formating 

    i.e., today = today.strftime("%d_%m_%Y") we can format as below 

    today='{d.day:02d}_{d.month:02d}_{d.year}'.format(d=today)

    It returns the same format.

     

    I hope it would help those facing the same problem.

     

    Regards,

    Vinothini Karumbayiram

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
11manish Profile Picture

11manish 249 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 198

#3
David_MA Profile Picture

David_MA 197 Super User 2026 Season 2

Last 30 days Overall leaderboard