Would some one help me looking at the script
Moderators: JRL, Dorian (MJT support)
Would some one help me looking at the script
I run this script to send email with the file name when the file come in to the system, but it did not give me the file name
=========================
//The incoming folder
Let>InFolder=W:\\HOTFOLDERS\Rumbo\success\
//Processed Log File
Let>ProcessedLog=W:\\HOTFOLDERS\Rumbo\success\processed.log
//Sendmail vars
GetDate>date
GetTime>time
Let>server=mailhost.chron.com
Let>to=[email protected]
//[email protected];
Let>from=[email protected]
Let>fromname=New Rumbo File
Let>subject=There is new Rumbo file!
Let>body=System has just processed a Rumbo page at %time% on %date% %CRLF%The name of the file is %files%.%CRLF%%CRLF%Thank you
//Label>mainloop
//Get a list of folders in InFolder
GetFileList>%InFolder%\*.*,file_list,;
Separate>file_list,;,files
//Loop through folder list
If>files_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>ThisFile=files_%k%
//Does this one exist in processed.log
Let>SendIt=TRUE
IfFileExists>ProcessedLog
ReadFile>ProcessedLog,ProcessedList
Position>ThisFile,ProcessedList,1,p
If>p>0
//This file already processed
Let>SendIt=FALSE
Endif
Endif
//Ok to process this file
If>SendIt=TRUE
//Write to processed log
WriteLn>ProcessedLog,r,ThisFile
//Send the file
SMTPSendMail>to,server,from,fromname,subject,body,Attachments
Endif
Until>k=files_count
Endif
//Wait>0.2
//Goto>mainloop
==========================
I got this email in the body:
"System has just processed a Rumbo page at 5:41:12 PM on 3/29/2007 The name of the file is %files%."
How can I make the %files% display the file name
thank you
=========================
//The incoming folder
Let>InFolder=W:\\HOTFOLDERS\Rumbo\success\
//Processed Log File
Let>ProcessedLog=W:\\HOTFOLDERS\Rumbo\success\processed.log
//Sendmail vars
GetDate>date
GetTime>time
Let>server=mailhost.chron.com
Let>to=[email protected]
//[email protected];
Let>from=[email protected]
Let>fromname=New Rumbo File
Let>subject=There is new Rumbo file!
Let>body=System has just processed a Rumbo page at %time% on %date% %CRLF%The name of the file is %files%.%CRLF%%CRLF%Thank you
//Label>mainloop
//Get a list of folders in InFolder
GetFileList>%InFolder%\*.*,file_list,;
Separate>file_list,;,files
//Loop through folder list
If>files_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>ThisFile=files_%k%
//Does this one exist in processed.log
Let>SendIt=TRUE
IfFileExists>ProcessedLog
ReadFile>ProcessedLog,ProcessedList
Position>ThisFile,ProcessedList,1,p
If>p>0
//This file already processed
Let>SendIt=FALSE
Endif
Endif
//Ok to process this file
If>SendIt=TRUE
//Write to processed log
WriteLn>ProcessedLog,r,ThisFile
//Send the file
SMTPSendMail>to,server,from,fromname,subject,body,Attachments
Endif
Until>k=files_count
Endif
//Wait>0.2
//Goto>mainloop
==========================
I got this email in the body:
"System has just processed a Rumbo page at 5:41:12 PM on 3/29/2007 The name of the file is %files%."
How can I make the %files% display the file name
thank you
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Program flow is an issue, but the other problem is that "files" is an array if it is assigned with
GetFileList>%InFolder%\*.*,file_list,;
Separate>file_list,;,files
so %files% doesn't work, it has to be %files_n%.
Or maybe you meant to use %ThisFile%?
I also see the mail send command includes attachments, but there's no associated definition.
GetFileList>%InFolder%\*.*,file_list,;
Separate>file_list,;,files
so %files% doesn't work, it has to be %files_n%.
Or maybe you meant to use %ThisFile%?
I also see the mail send command includes attachments, but there's no associated definition.
I did both of the suggestions, but it still did not work
This is what I got:
System has just processed a Rumbo page at 10:12:39 AM on 3/30/2007 The name of the file is %ThisFile%.
Thank you
============================================
and this is the scripts
//The incoming folder
Let>InFolder=W:\\HOTFOLDERS\Rumbo\success\
//Processed Log File
Let>ProcessedLog=W:\\HOTFOLDERS\Rumbo\success\processed.log
//Sendmail vars
GetDate>date
GetTime>time
Let>server=mailhost.chron.com
Let>to=[email protected]
//[email protected];
Let>from=[email protected]
Let>fromname=New Rumbo File
Let>subject=There is new Rumbo file!
//Label>mainloop
//Get a list of folders in InFolder
GetFileList>%InFolder%\*.*,file_list,;
Separate>file_list,;,files
Let>body=System has just processed a Rumbo page at %time% on %date% %CRLF%The name of the file is %ThisFile%.%CRLF%%CRLF%Thank you
//Loop through folder list
If>files_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>ThisFile=files_%k%
//Does this one exist in processed.log
Let>SendIt=TRUE
IfFileExists>ProcessedLog
ReadFile>ProcessedLog,ProcessedList
Position>ThisFile,ProcessedList,1,p
If>p>0
//This file already processed
Let>SendIt=FALSE
Endif
Endif
//Ok to process this file
If>SendIt=TRUE
//Write to processed log
WriteLn>ProcessedLog,r,ThisFile
//Send the file
SMTPSendMail>to,server,from,fromname,subject,body,
Endif
Until>k=files_count
Endif
//Wait>0.2
//Goto>mainloop
DeleteFile>%InFolder%\*.*
System has just processed a Rumbo page at 10:12:39 AM on 3/30/2007 The name of the file is %ThisFile%.
Thank you
============================================
and this is the scripts
//The incoming folder
Let>InFolder=W:\\HOTFOLDERS\Rumbo\success\
//Processed Log File
Let>ProcessedLog=W:\\HOTFOLDERS\Rumbo\success\processed.log
//Sendmail vars
GetDate>date
GetTime>time
Let>server=mailhost.chron.com
Let>to=[email protected]
//[email protected];
Let>from=[email protected]
Let>fromname=New Rumbo File
Let>subject=There is new Rumbo file!
//Label>mainloop
//Get a list of folders in InFolder
GetFileList>%InFolder%\*.*,file_list,;
Separate>file_list,;,files
Let>body=System has just processed a Rumbo page at %time% on %date% %CRLF%The name of the file is %ThisFile%.%CRLF%%CRLF%Thank you
//Loop through folder list
If>files_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>ThisFile=files_%k%
//Does this one exist in processed.log
Let>SendIt=TRUE
IfFileExists>ProcessedLog
ReadFile>ProcessedLog,ProcessedList
Position>ThisFile,ProcessedList,1,p
If>p>0
//This file already processed
Let>SendIt=FALSE
Endif
Endif
//Ok to process this file
If>SendIt=TRUE
//Write to processed log
WriteLn>ProcessedLog,r,ThisFile
//Send the file
SMTPSendMail>to,server,from,fromname,subject,body,
Endif
Until>k=files_count
Endif
//Wait>0.2
//Goto>mainloop
DeleteFile>%InFolder%\*.*
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Still need to move Let>Body line happen after defining %ThisFile%
Try moving it like this:
Try moving it like this:
Code: Select all
//Get a list of folders in InFolder
GetFileList>%InFolder%\*.*,file_list,;
Separate>file_list,;,files
//Loop through folder list
If>files_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>ThisFile=files_%k%
Let>body=System has just processed a Rumbo page at %time% on %date% %CRLF%The name of the file is %ThisFile%.%CRLF%%CRLF%Thank you
//Does this one exist in processed.log
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Very close to accomplish the task
I have made the change to the script to make it simpler, and I got this email:
System has just processed a Rumbo page at 11:47:46 AM on 3/30/2007
The name of the file is W:\\HOTFOLDERS\Rumbo\success\0330rumboHp02 copy.PDF.
How can I just display the name of the file "0330rumboHP02 copy.pdf" not the whole path
thank you
=========================================
here is the script
//The incoming folder
//Let>InFolder=W:\\HOTFOLDERS\Rumbo\success\
//Processed Log File
//Let>ProcessedLog=W:\\HOTFOLDERS\Rumbo\success\processed.log
//Sendmail vars
GetDate>date
GetTime>time
Let>server=mailhost.chron.com
Let>to=[email protected]
//[email protected];
Let>from=[email protected]
Let>fromname=New Rumbo File
Let>subject=There is new Rumbo file!
GetFileList>W:\\HOTFOLDERS\Rumbo\success\*.*,files
Let>body=System has just processed a Rumbo page at %time% on %date% %CRLF%The name of the file is %files%.%CRLF%%CRLF%Thank you
//Send the file
SMTPSendMail>to,server,from,fromname,subject,body,
DeleteFile>%InFolder%\*.*
System has just processed a Rumbo page at 11:47:46 AM on 3/30/2007
The name of the file is W:\\HOTFOLDERS\Rumbo\success\0330rumboHp02 copy.PDF.
How can I just display the name of the file "0330rumboHP02 copy.pdf" not the whole path
thank you
=========================================
here is the script
//The incoming folder
//Let>InFolder=W:\\HOTFOLDERS\Rumbo\success\
//Processed Log File
//Let>ProcessedLog=W:\\HOTFOLDERS\Rumbo\success\processed.log
//Sendmail vars
GetDate>date
GetTime>time
Let>server=mailhost.chron.com
Let>to=[email protected]
//[email protected];
Let>from=[email protected]
Let>fromname=New Rumbo File
Let>subject=There is new Rumbo file!
GetFileList>W:\\HOTFOLDERS\Rumbo\success\*.*,files
Let>body=System has just processed a Rumbo page at %time% on %date% %CRLF%The name of the file is %files%.%CRLF%%CRLF%Thank you
//Send the file
SMTPSendMail>to,server,from,fromname,subject,body,
DeleteFile>%InFolder%\*.*
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Thank you both for yourhelp.
Thank you for your help it works great. I am just a bad coder
Also I want to omid the extention in the file name FILExxx.PDF
I just want to display FILEXXX, not the pdf part.
The MidStr function is >string,start,length,result
Is there any function to >string,end,length,result?
thanks
Also I want to omid the extention in the file name FILExxx.PDF
I just want to display FILEXXX, not the pdf part.
The MidStr function is >string,start,length,result
Is there any function to >string,end,length,result?
thanks
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
You can do that by finding the length of the string and then calculating how many characters you want from the start, like:
Let>filename=myfile.txt
Len>filename,lfile
Let>lfile=lfile-4
MidStr>filename,1,lfile,nufile
MDL>%nufile%
But in this case it is easier to use Separate> again to split the filename at the period:
Let>filename=myfile.txt
Separate>filename,.,pce
MDL>%pce_1%
Let>filename=myfile.txt
Len>filename,lfile
Let>lfile=lfile-4
MidStr>filename,1,lfile,nufile
MDL>%nufile%
But in this case it is easier to use Separate> again to split the filename at the period:
Let>filename=myfile.txt
Separate>filename,.,pce
MDL>%pce_1%
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Doesn't matter how long the filename or the extension is - the following will find the position of the dot (period) between name and extension and extract everything up until the dot:
Let>filename=c:\dir\somefile.ext
Position>.,filename,1,pdot
Let>pdot=pdot-1
MidStr>filename,1,pdot,filename
MessageModal>filename
Let>filename=c:\dir\somefile.ext
Position>.,filename,1,pdot
Let>pdot=pdot-1
MidStr>filename,1,pdot,filename
MessageModal>filename
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?