Jump to content
Macro Express Forums

Cool 'monitor Folder' Work-around


Cory
 Share

Recommended Posts

I have been using ME to scan thousands of documents for a client with great success and learned a cool workaround in ME. You see the high capacity scanners we are using output directly to PDF on a network folder so I wanted to monitor the folders for any new files as part of a file disposal macro. Problem is I don’t know what the file name would be as it incrementally changes. I was disappointed to find ME had no capability to monitor a folder for change and also tried Wait For File Exist with the value of *.* but it didn’t work. This would only work if the folder was empty which was my case. So I wrote an elaborate routine to do so and as I was debugging it I found a cool trick. I assumed wildcards were out but they’re not! In this case I have it waiting for *.pdf and it works! Also other wildcards like C850*.* work. The only limitation is that you must ensure that no files already exist that match that criteria in the folder of course but a lot of the time this works great if you know part of the file name.

 

Anyway I just thought I would give a little back today.

Link to comment
Share on other sites

Hi Cory,Great to know!

 

Here is a Wait for increase number of files in a directory, longhand, for interest or improvement.

<TVAR2:01:10:><TMVAR2:19:01:00:000:000:FolderName><REP3:07:000001:000001:0001:0:01:%FolderName%><NMVAR:08:01:0:0000001:0:0000000><ENDREP><TVAR2:01:01:%N1%><TMVAR2:19:01:00:000:000:NumberFiles><REP3:08:000002:000001:0001:0:01:%NumberFiles%><IVAR2:01:01:0><IMSD:50><REP3:07:000001:000001:0001:0:01:%FolderName%><NMVAR:08:01:0:0000001:0:0000000><ENDREP><TVAR2:01:01:%N1%><ENDREP><TBOX4:T:1:CenterCenter000278000200:000:New Filethere are %N1% files in the folder

T1=%T1%

NumberFiles=%NumberFiles%

N1=%N1%>

Variable Set String %T1% from Folder Name

Variable Modify String: Save %T1% to Environment Variable

Repeat with Folder

  Variable Modify Integer: Inc (%N1%)

Repeat End

Variable Set String %T1% "%N1%"

Variable Modify String: Save %T1% to Environment Variable

Repeat Until %T1% <> "%NumberFiles%"

  Variable Set Integer %N1% to 0

  Delay 50 Milliseconds

  Repeat with Folder

    Variable Modify Integer: Inc (%N1%)

  Repeat End

  Variable Set String %T1% "%N1%"

Repeat End

Text Box Display: New File

Best, Randall
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...