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 Platform Community / Forums / Power Automate / Python in PAD Editing ...
Power Automate
Answered

Python in PAD Editing String Flow Variables

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hey all, 

 

I am trying to get the metadata from .txt files saved locally in a folder on my machine. Unfortunately, this is not possible using the core functionality. So I am using Python. I have written a script that works in Visual Studio in Python 2.7. 

 

When I transfer it across to PAD, it throws an error. 

 

After some digging, I have found that the issue is likely to be the way that string flow variables are used/translated between Python and PAD. I have made an example setup (with general filenames etc), pictured below:

 

Tymms_A_0-1665760198964.png

What this does, is that it gets the files in a folder. 

For each file in the folder, it runs 2 Python scripts (one wrong and one right, so we can compare to see what is happening). 

The wrong script creates variables named PythonWrong and ScriptErrorWrong, and has the code 

     print("""%CurrentItem%"")

The right script creates variables named PythonRight and ScriptErrorRight, and has the code

    print("""%CurrentItem%""")

 

As you can see, the location of the Files is C:\desktop\testing. The error thrown is what you would expect with 1 less " (see below).

Tymms_A_1-1665760490550.png

 

However, in the flow variable PythonRight (pic 1), you can see the large gap between C:\desktop and esting.

 

This, to me implies that it is taking the \t as some kind of formatting command (being 'insert tab', I assume) rather than just being part of the string. 

 

Does anyone here know how to either stop Python or PAD (I have no idea which of the 2 is doing this) looking for formatting commands, or ignoring any it finds?

 

Many Thanks

  • VJR Profile Picture
    7,635 on at

    Hello @Tymms_A 

    While you continue to look for a solution on the Python script, can you share what are you trying to achieve on each of the files in the folder? 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I am trying to get the file title, file creation date, number of lines of text, the first line of the text and the third line of the text in about 1800 .txt files in the same folder, and export the information into an excel spreadsheet. 

    A piece of label software that we use only saves any information about what has been printed in individual .txt files based on jobs (one .txt file per job). I'm putting together a scrape automation to be able to use the data we have.

    Unfortunately, it is not possible with the current options to get the file creation date, so I am therefore scripting it with the (very useful) scripting options.

  • Verified answer
    VJR Profile Picture
    7,635 on at

    Hi @Anonymous 

     

    Here is how you can achieve what you are looking for with the existing available actions.

     

    Get the File Name and Creation Date:

    VJR_0-1665997443544.png

     

    Using:

    FileName: %CurrentItem.Name%
    FileCreationDate: %CurrentItem.CreationTime.Day%/%CurrentItem.CreationTime.Month%/%CurrentItem.CreationTime.Year%

     

     

     

    Then Read the Text file and Split it using Newline to get the Number of lines, 1st line and 3rd line

    VJR_1-1665997578155.png

     

    TotalLines: %TextList.Count%
    First Line: %TextList[0]%
    Third Line: %TextList[2]%

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Awesome, thank you! I didn't know that you could run methods on the variables! Is there a list anywhere of the methods that you can run on the different variable types?

  • VJR Profile Picture
    7,635 on at

    The different methods on a variable can be seen using a Display box

     

    Select the required variable using the {x} button.

    Expand the variable and it will show the list of supported methods pertaining to that variable.

     

    VJR_0-1666689922642.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Awesome! Thank you so much!

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 229 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 223 Super User 2026 Season 2

#3
Valantis Profile Picture

Valantis 136 Super User 2026 Season 2

Last 30 days Overall leaderboard