community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
#SANTALYTICS

The highly anticipated Alteryx Community tradition is back! We hope you'll join us!

Learn More

Macro that checks if a file is locked

Fireball

Hi,

 

About a week ago I posted a question about how to best check if a file is locked.  I have some workflows that read in a shared yxdb file and sometimes that yxdb is being updated when a workflow attempts to read it, and so the workflow throws an error and skips that input, which results in me having to re-run the workflow once I receive the error email.

 

The response from @ScottJ gave me the guidance and inspiration I needed to put together a macro that does exactly what I needed.  Specifically:

 

  • It takes in a file and directory as inputs and checks if that file is currently locked.
  • If it is locked, it waits X seconds before trying again, until the maximum iterations are reached.

I added some steps to identify if the file and directory actually exist, whether a sheet name is provided (in the case of Excel files), and set it up to handle (as of now) three different types of input (yxdb, Excel and CSV...the most common input files we work with). 

lock check macro.png

 

 I suspect there are ways to make this more robust and handle more use-cases, but since I hadn't seen anything like this out there yet, I figured I'd share it with the community in its current state to both help others who might be facing a similar challenge as well as to see if anyone might have ideas on how to make this macro better.  I haven't worked with macros too much (and this was my first exposure to batch files), so I am sure there is a lot I can learn. :-)

 

-Mike

 

 

Highlighted
Meteoroid

This is a great tool to have.
It would be great if there was a field output by the directory tool to detect locked files..

Bolide

Here's a related idea, if you'd like to add a Star:

 

File Management tools (copy, rename, delete)

 

https://community.alteryx.com/t5/Alteryx-Designer-Ideas/File-Management-tools-copy-rename-delete/idc...

 

under the comments, I added "+determining if a file is locked "

Labels