Page 1 of 2

Auto-move file to category folders

Posted: Sun Oct 23, 2005 3:35 pm
by Prem
I have been looking a long time for a document-archiving watched folder utility that moves files according to category name. I didnt find a proper one, therefore would like to make one myself, but I need some help, I'm a beginner with robotask.
A watched folder that looks for new documents every 5 minutes;
If a new document is found, check if the filename contains one of the category codes.
If the document name contains "Cat1-" then move the file to the folder d:\Category1 
If the document name starts with "Cat2-" then move the file to the folder d:\Category2
.. etc.. up to Cat5-
If no category code is found in the filename,

move file to folder c:\ToBeRenamed
and send email containing the link to the webfolder http://domain/toberenamed
Any help is very welcome, ...
Prem 

Auto-move file to category folders

Posted: Sun Oct 23, 2005 11:50 pm
by Prem
I have managed to make the first part work: move according to category code. I just made 5 seperate tasks, each moving files that start with the category code (with wildcards). (I dont know if making an if/then nested loop 5 levels deep takes less work for the computer to perform?). The emailing when unsuccessful is still a problem.. 

Auto-move file to category folders

Posted: Mon Oct 24, 2005 12:41 am
by Oleg
You may use a non nested construction, like this:

file loop
   if "cat1-" is contained in filename then
      move file to d:\category1 folder
      continue
   end if
   if "cat2-" is contained in filename then
      move file to d:\category2 folder
      continue
   end if
   if "cat3-" is contained in filename then
      move file to d:\category3 folder
      continue
   end if
   if "cat4-" is contained in filename then
      move file to d:\category4 folder
      continue
   end if
   if "cat5-" is contained in filename then
      move file to d:\category5 folder
      continue
   end if
   move file to c:\ToBeRenamed folder
end loop
The emailing when unsuccessful is still a problem..
Sorry, I haven't understood something. When do you want to send the message? What do you mean under unsuccessful? When no files have moved to c:\ToBeRenamed? Describe in more detail, please. I shall try to write an examle.

Auto-move file to category folders

Posted: Mon Oct 24, 2005 2:10 am
by Prem
Thank you for the non-nested construction!
Because the categorizing method is used by the system, no input dialogs can be used to add a category code or to rename a file. My solution is the following, to rename a file by email:
If the filename is not starting with a a category code:

move file to folder c:\ToBeRenamed
and send email with the following text in the body:
---------
Robotask could not find the category code of file [uncatfilename.doc]. Please fill in the following details and email to robotask@domain.com / click Reply. (Exclude file extension and do not use spaces)
Add Category code:
or
Replace whole filename:
--
(I have linked robotask@domain.com to a public email-enabled folder in Exchange 2003)
The following two task needs to be done by Robotask:
IF an email (extension .EML) is received in the folder M:\DOMAIN.NL\PUBLIC FOLDERS\WSS
THEN search the contents of the email for the strings: "code:" and "filename:"
IF there is a word (therefore not being the word "or") behind "code:"
THEN

read the word directly following the "code:" and give the variable ADDCODE the string that it reads.
Search for the file named [uncatfilename.doc] and put the varable ADDCODE in front of the filename.
ELSE

read the word after "filename:" and give the variable NEWNAME the string it reads.
Search for the file named [uncatfilename.doc] and replace the  part of the filename before the file extension with NEWNAME.
What do you thing about this solution and how should it be written? Thank you for your assistance
 

Auto-move file to category folders

Posted: Mon Oct 24, 2005 2:30 am
by Prem
What I also want to add is the funcionality to email as attachments the new documents in a watched folder "c:\tobemailed"
The following filenaming will be used by the user who want to auto-email a document:
MAIL-[recipient@domain.com]-[filename].[extension]
IF the filename start with string "mail-",
THEN

remove that the string "MAIL-[recipient@domain.com]-" from the filename.
email  the file as an attachment to [recipient@domain.com]
Maybe I should put this in a new post in the forum?

Auto-move file to category folders

Posted: Mon Oct 24, 2005 3:15 am
by Oleg
1. remove that the string "MAIL-[recipient@domain.com]-" from the filename.
2. email the file as an attachment to [recipient@domain.com]
In order to make such analysis of file name you must use Basic script. Download Basic Plugin for Robotask here.
Can you write scripts on Basic language?

Auto-move file to category folders

Posted: Mon Oct 24, 2005 3:33 am
by Prem
Thanks. No i cannot write basic, sorry, but I will try to learn the basics of basic, if I can use it in this case.

Auto-move file to category folders

Posted: Mon Oct 24, 2005 8:56 am
by Oleg
I think that better to do so:
1. put non-categorized file to c:\ToBeRenamed
2. send email notification

Anyway you (or some user) must change file name manually. You should look at "c:\ToBeRenamed" folder and decide, what you must do with these files. Sorry, I don't know your task in detail.

You task should look so:
file loop
   if "cat1-" is contained in filename then
      move file to d:\category1 folder
      continue
   end if
   if "cat2-" is contained in filename then
      move file to d:\category2 folder
      continue
   end if
   if "cat3-" is contained in filename then
      move file to d:\category3 folder
      continue
   end if
   if "cat4-" is contained in filename then
      move file to d:\category4 folder
      continue
   end if
   if "cat5-" is contained in filename then
      move file to d:\category5 folder
      continue
   end if
   move file to c:\ToBeRenamed folder
   send email (with filename or file in attachment)
end loop

So, email notification will be sent only when some file will be moved into c:\ToBeRenamed folder.

Auto-move file to category folders

Posted: Mon Oct 24, 2005 9:14 am
by Oleg
If you want to rename files with helping of email messages, you should specify old file name and new file name.
For example:

RoboTask Renaming Begin
uncatfilename.doc
cat1-newfilename.doc

1-st string is a some signature for RoboTask which talk that next two line contain old filename and new filename.
This email message must be in text format. If it will contain HTML or base64 encoded text, you should have some special utility or Basic script.

Auto-move file to category folders

Posted: Tue Oct 25, 2005 11:33 am
by Prem
Thanks for your help.
The task RoboTask Renaming Begin, is that a pre-set task in Robotask or do I have to create such a task (as example) myself? Where can i find it in the Robotask menu's?