Automatic run a windows script when a file is added to a windows folder

By gbmelby ·
Hi all Windows scripting experts

I have a question how to set up automatic start of a .batscript on Windows 2008.

Example description:
We recieve a file from the CRM-system with general ledger (GL) transactions every evening that is later loaded into the ERP system (IFS Applications). Usually is this process followed.

1. An Oracle package/procedure (in the CRM-system) stores GL files in folder "CRM_GL_FILES" on a file server every evening at 1830.
2. A Windows .bat script to rename the files to a fix naming standard runs every evening at 1900 using Windows scheduled tasks.
3. A scheduled job in IFS Applications loads the GL files in folder "CRM_GL_FILES" starting 1**5.

Usually this process works fine, but some times is the Oracle package/procedure in the CRM-system delayed and GL-files are stored in folder "CRM_GL_FILES" later than 1900. Further automation of this process is required.

Is it any function in Windows 2008 to automatic run the rename bat-script when GL-files are loaded to folder "CRM_GL_FILES"?
Is it possible in Windows scheduled tasks to run two or more scripts a task Chain so that the load procedure of GL-files to IFS ERP-system starts when the renaming is completed.

All suggestions and tips are welcome.

Thanks in advance.

Best regards

Gunnar B Melby
System Manager
Energiselskapet Buskerud, Norway

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Poll The Folder For Files Each Hour.

by Vallum Halo In reply to Automatic run a windows s ...

One possible solution would be to schedule a task every hour, and that task would process any files in the CRM_GM_FILES (if they exist.) That way, the files would be renamed in at least one hour.

Note -- Most of the time the script would simply exit (because no files existed.) But if a file existed, the Rename batch script would execute to completion.

I am having a little problem following your logic above. For example, when you say "Chain" scripts together, are you aware that one batch file can simple execute another batch file using the standard batch "Call" command?

If you are looking for specific batch file syntax to accomplish the above (such as how to see if any file exists in a directory) let me know and I can elaborate with some techniques I would use for this.

Collapse -

Reply to suggested solution "Poll The Folder For Files Each Hour"

by gbmelby In reply to Poll The Folder For Files ...

Thanks for Your reply.
Your suggested solution seems interesting. I would be grate if it is possible to include any logic in the rename script program code to start an other program to load data into the ERP system.

File "Ident14_110820141800.csv" is loaded to folder CRM_GL_FILES ("110820141800" is date/time when the file is loaded and is different each time loading a file).

The rename script running is very simple;
rename F:\CRM_GL_FILES\Ident14* ELWIN_BILAGSFIL_slk14.csv

"ELWIN_BILAGSFIL_slk14.csv" is the fixed file name required by the load procedure in IFS Applications ERP-system.
Today the data load starts as a scheduled job in IFS and runs even if a file renamed or not. It would be a great improvement if the load procedure in IFS could start if a file in «CRM_GL_FILES» is renamed and do not start if no file is renamed.
If rename is succesfull, the rename script should execute windows script «load_IFS_data.bat» to start the load procedure into IFS.

sqlplus /nolog @F:\Scripts\load_IFS_data.sql

code in sql-script «load_IFS_data.sql»;
connect <username>/<password>@<database_name» as sysdba;


SCHEDULE_ID_ := 378;


IFS background job to load data is then started by a windows script and not a scheduled task defined in IFS.

All suggestions are welcome.

Thanks and regards

Gunnar B Melby

Back to Windows Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums