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
Unanswered

Python Coding in PAD

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am trying to find the metadata (specifically the creation date) for a .txt file. (Well, a folder of them, but one at a time in each iteration of the loop). 

 

The folder is located on a server, so has a location address (C: etc) not a web address or Sharepoint etc. 

 

To do this, I have done the following steps:

1. Get files in folder - Var: Files

For Each Current Item in Files

  2. Get File Path Part - Var: Directory, FileName, FileNameNoExtension

  3. Run Python Script - Var: PythonScriptOutput

           import sys
          sys.path.append(r"c:\Python27\Lib")
          import os
          import datetime
          from datetime import date
          filename = """%CurrentItem%"""
          createdDate = os.path.getctime(filename)
          createdDateFormat = date.fromtimestamp(createdDate)
          print(createdDateFormat)

End 

 

I cannot for the life of me work out why the Python is not working. The other variables get filled, but not the PythonScriptOutput.

  • ThomasFonn Profile Picture
    273 on at

    are you sure the "r" in sys.path.append(r"c:\Python27\Lib") is supposed to be there?

    Are you also generating a ScriptError* variable from the "Run Python script"-action in PAD?
    Maybe there's some insight there?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for your reply!

     

    The r in the append method means that its only going to read from the address mentioned. 

     

    The script error says Traceback. 

    What I am thinking is happening (and has been happening in many different places) is that something is changing the string of the location. I've seen it before. I tested it, and if I just put in

    print("""%VariableLocation%"")

    (so without one of the "), then the VariableLocation translates across fine, which is shown in the ScriptError.

     

    When I make a step with 

    print("""%VariableLocation%""")

    then the VariableLocation loses some of it's characters (the first \a or \b so far). 

     

    I'm going to make another thread for the issue of losing the characters, as its a large and problematic issue in itself.

     

    Thank you again!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I have created the follow up to this, with the core problem. The new thread can be found at:
    https://powerusers.microsoft.com/t5/Power-Automate-Desktop/Python-in-PAD-Editing-String-Flow-Variables/td-p/1818763 

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 237 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 194

Last 30 days Overall leaderboard