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 - Does not impo...
Power Automate
Answered

Python - Does not import os and import glob

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hey all,

 

Im trying to run a script that finds the most recently modified file in a folder and returns the file path. The python script works perfectly in Atom but for some reason, import os & glob are not recognised. 


Does anyone know of a way around this? Or point me in the right direction?

 

Junior engineer here looking to impress my boss by automating the payroll process 

Capture.PNG

Categories:
I have the same question (0)
  • fraenK Profile Picture
    2,125 on at

    Did you add the lib folder of your Python installation under "Module folder paths"?

     

    But you don't need Python fir this, just use the get files in folder action and set the sorting to last modified:

    https://docs.microsoft.com/en-us/power-automate/desktop-flows/actions-reference/folder#getfiles

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for the response. 

     

    I did try this already. HCapture.PNG

     

    owever, I need a file path (file path of the latest modified file in the folder) as an input argument to launch excel. I do not know how to pick the first item from the sorting list by last modified. Do you know of a way to do this?

  • Verified answer
    fraenK Profile Picture
    2,125 on at

    When you use this:

    https://docs.microsoft.com/en-us/power-automate/desktop-flows/actions-reference/folder#getfiles

    it outputs "The retrieved files as a list of file objects"

     

    Lists are described here: https://docs.microsoft.com/en-us/power-automate/desktop-flows/variable-data-types#advanced-data-types

    To retrieve a specific item of a list, use the following notation: %VariableName[ItemNumber]%

     

    Files object is described here:

    https://docs.microsoft.com/en-us/power-automate/desktop-flows/datatype-properties#files

     

    So file path of first file would be:

    %VariableName[0].FullName%

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    fraenk you are a legend. Thank you 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 570

#2
Valantis Profile Picture

Valantis 405

#3
11manish Profile Picture

11manish 350

Last 30 days Overall leaderboard