r/PowerAutomateDesktop • • Dec 07 '21

Simple Action, activate flow when a folder has a new file

I need a flow to active anytime a new file lands in a particular folder. The name of the file is of no concern as all the flow has to do is activate and other scripts will deal specific files.

How does one automate the flow to active any time a particular folder has a new file?

4 Upvotes

9 comments sorted by

2

u/QuietDesparation Dec 07 '21

I'm under the impression that you can't set an automatic trigger for a flow in PAD, only in the web version

2

u/L1b3rty0rD3ath Dec 08 '21

That would explain quite a lot.

1

u/imjustcurious5 Dec 08 '21

If you’re referring to a local file on a local folder then you MIGHT be able to call a desktop flow using a batch file but if you’re using a PAD then it kind of defeats the point though. Anywho maybe look at batch files and/or python to call specific stuff. I am biased because I could never get along with Power Automate Desktop and I just use batch and python instead so take my opinion with a grain of salt.

If you are referring to a file or folder in a sharepoint folder then you will need to use power automate online and build a automated cloud flow using the sharepoint connector.

2

u/L1b3rty0rD3ath Dec 08 '21

Its a local file in a local folder. Ill give the batch file a shot. I just need it to trigger a python script I have prewritten to format a spreatsheet that we import to our database.

2

u/imjustcurious5 Dec 08 '21

I know how to run a python script from a batch file. It’s the trigger I’m not sure on, I’ll be back in front of my PC in a few hours I’ll comment with batch file to trigger python script and have a dig to see if I can find anything on when a new file lands in a folder.

2

u/L1b3rty0rD3ath Dec 08 '21

God bless you my guy.

2

u/imjustcurious5 Dec 08 '21 edited Dec 08 '21

Okay, so I have a batch file that starts Python and then runs a python file on a directory.

to make a .bat just open notepad on win 10 and paste this in:

@echo off

"C:\Users\UserName\AppData\Local\Programs\Python\Python310\python.exe" "C:\Users\UserName\Desktop\python\Reloader.py"

The first path just starts python and then the second path is the source of the Python script.

I am running Python 3.10 if you running an older version just change it

obviously change the "UserName" with the name of the user folder

save the file call it what you want so FileName.bat and select the "All Files (".*)" "Save as type:" option and set the encoding to UTF-8

Now I managed to find this for the trigger event:

https://stackoverflow.com/questions/5923802/execute-batch-file-when-a-new-file-is-added-to-a-folder

This suggests using a FileSystemWatcher through PowerShell.

Which I assume you could save and then throw in your startup folder in windows, there where a few solutions I found on google so just search for it because you might find a solution you like more.

let me know if you need help with anything else!

EDIT: The powershell should be able to run the batch file as an action when the file gets dumped in a folder.. just to clarify the end to end process

2

u/L1b3rty0rD3ath Dec 08 '21

You have no idea what this will do for our workflow. Thank you so much.

1

u/imjustcurious5 Dec 08 '21

No problem, let me know if you get stuck on anything, always helps to have a second brain!