Jump to content
Macro Express Forums

Process Files On Folder


Raul

Recommended Posts

I need some suggestions on how to accomplish this. I want to be able to process all files that are put in a folder one by one until there are no more files in the folder. In other words, users are putting files in a folder and I want to be able to run a macro on each file (open the file, convert to HTML, etc- this part is done) in the folder, delete the file that I just processed and go on to the next one if there are any more files.

 

I can run the macro at certain intervals but I don't know how to tell it to check and see if there any files in that folder and then open that file with any program (Word, IE, etc.).

 

Any suggestions are appreciated.

 

Thank you, Raul

Link to comment
Share on other sites

I have some macros that do this and it's pretty easy. Run your macro on a schedule and create an infinite repeat loop. You can do this by using ‘repeat until’ and set the argument to T1<>T1. This means T1 does not equal T1 which of course can never be. Then in that loop add a sleazy ‘repeat with folder’. What I do is ‘repeat with folder’, then ‘break’, then end repeat. This gives me the full file name and path for the first file in the folder and keeps moving on. Let’s say we store that in T3. I then add an ‘If T2=””’ meaning if the variable T2 from the repeat with folder is empty. In the If –Endif I put another break. This way when the folder is empty it bails out. After this but before the last repeat end I would us the “Activate or Launch” to open my file and do whatever next. Let’s say it’s a PDF you want to save as HTML. You don’t need to specify Acrobat.exe and all that jazz. Simply use the “Launch Program only” and put T2 in there. The title is misleading. As long as there is a file association from PDF to Acrobat you only need specify the file name in the Program path/Name field. Now just text type the commands to do the ‘save as’ and close the file. Then you can move, delete or whatever before the final repeat end.

Link to comment
Share on other sites

Oh, and you can just do a repeat with folder as well. But if the contents of the folder change while the macro is running youcan get weird results depending on their names. My first example also assume you are moving or deleting the files as they are being processed.

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...
×
×
  • Create New...