How to get the top file name and insert into variables?

Discuss RoboTask here

How to get the top file name and insert into variables?

Postby danger.ngai » Fri Jun 14, 2019 3:28 am

First, what I want to do is:
I need to upload the pdf file existed in specific folder to ERP system ONE BY ONE.
The file name already contains the information I needed to input ERP system, which is

Date_ReportNo_ProjectNo.pdf

So I need to :
1. Run the autotask when the specific folder has a new pdf file
2. Scan the 1st pdf file and get its file name.
3. Divided the name into 3 variables, which are, {Date},{ReportNo},{ProjectNo}
4. Open the webpage and login ERP system, type the 3 variables in specific field and upload the pdf file step by step.
5. Move the uploaded PDF from A folder to B folder.
6. Repeat the task if there is another PDF file after Step 5. Otherwise, end until a new PDF exist.

Any suggestions to do step 2,3,4?
Those always required the source location, but I am not using the fixed file, the PDF will keep changing.
How can I setup "select the 1st file in the folder"?
Attachments
Capture.JPG
Capture.JPG (24.57 KiB) Viewed 1931 times
danger.ngai
 
Posts: 7
Joined: Thu Jun 13, 2019 4:31 am

Re: How to get the top file name and insert into variables?

Postby Oleg » Mon Jun 17, 2019 11:03 am

Look at the example below. You can parse the name of file by using regular expressions.
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1040932817
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task565"
Hide=INTEGER|0
ID=INTEGER|-1724333428
LogOnAsUser=INTEGER|1
Name=STRING|"Parse file name"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PDFFOLDER"" with value ""D:\incoming\pdf"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"PDFFOLDER"
varvalue=STRING|"D:\incoming\pdf"

[Actions\Action10]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action11]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""The name {fileName} does not match!"""
Params=FOLDER

[Actions\Action11\Params]
icon=STRING|"3"
msg0=STRING|"The name {fileName} does not match!"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action12]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action13]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action2]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action2\Params]
createmode=STRING|"1"
date1=STRING|"20190617"
date2=STRING|"20190617"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{PDFFolder}\*.pdf"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER

[Actions\Action3\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{FileName}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?i)(\d+)_([^_]+)_([^\.]+)\.pdf"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"match"

[Actions\Action4]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action4\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{match}"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{expr}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"{expr}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""DT"" with value ""{expr(1)}"""
Params=FOLDER

[Actions\Action6\Params]
=STRING|""
expand=STRING|"1"
varname=STRING|"DT"
varvalue=STRING|"{expr(1)}"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""REPORTNO"" with value ""{expr(2)}"""
Params=FOLDER

[Actions\Action7\Params]
=STRING|""
expand=STRING|"1"
varname=STRING|"REPORTNO"
varvalue=STRING|"{expr(2)}"

[Actions\Action8]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PROJECTNO"" with value ""{expr(3)}"""
Params=FOLDER

[Actions\Action8\Params]
expand=STRING|"1"
varname=STRING|"PROJECTNO"
varvalue=STRING|"{expr(3)}"

[Actions\Action9]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""file name: {filename}"""
Params=FOLDER

[Actions\Action9\Params]
icon=STRING|"1"
msg0=STRING|"file name: {filename}"
msg2=STRING|"date: {dt}"
msg3=STRING|"Report No: {ReportNo}"
msg4=STRING|"Project No: {ProjectNo}"
msgcount=STRING|"5"
playsound=STRING|"0"
showmessage=STRING|"1"


I tested it on folder contains such files:
20190606_SK37-0619-1_DECL632.pdf
20190606_SK38-0619-1_DECL632.pdf
20190608_SK66-0619-1_DECL632.pdf
20190609_SK39-0619-1_DECL632.pdf
Oleg Yershov
Oleg
Site Admin
 
Posts: 2455
Joined: Thu Jan 01, 1970 1:00 am

Re: How to get the top file name and insert into variables?

Postby danger.ngai » Fri Jun 21, 2019 11:47 am

Oleg wrote:Look at the example below. You can parse the name of file by using regular expressions.
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1040932817
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task565"
Hide=INTEGER|0
ID=INTEGER|-1724333428
LogOnAsUser=INTEGER|1
Name=STRING|"Parse file name"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PDFFOLDER"" with value ""D:\incoming\pdf"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"PDFFOLDER"
varvalue=STRING|"D:\incoming\pdf"

[Actions\Action10]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action11]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""The name {fileName} does not match!"""
Params=FOLDER

[Actions\Action11\Params]
icon=STRING|"3"
msg0=STRING|"The name {fileName} does not match!"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action12]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action13]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action2]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action2\Params]
createmode=STRING|"1"
date1=STRING|"20190617"
date2=STRING|"20190617"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{PDFFolder}\*.pdf"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER

[Actions\Action3\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{FileName}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?i)(\d+)_([^_]+)_([^\.]+)\.pdf"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"match"

[Actions\Action4]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action4\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{match}"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{expr}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"{expr}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""DT"" with value ""{expr(1)}"""
Params=FOLDER

[Actions\Action6\Params]
=STRING|""
expand=STRING|"1"
varname=STRING|"DT"
varvalue=STRING|"{expr(1)}"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""REPORTNO"" with value ""{expr(2)}"""
Params=FOLDER

[Actions\Action7\Params]
=STRING|""
expand=STRING|"1"
varname=STRING|"REPORTNO"
varvalue=STRING|"{expr(2)}"

[Actions\Action8]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PROJECTNO"" with value ""{expr(3)}"""
Params=FOLDER

[Actions\Action8\Params]
expand=STRING|"1"
varname=STRING|"PROJECTNO"
varvalue=STRING|"{expr(3)}"

[Actions\Action9]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""file name: {filename}"""
Params=FOLDER

[Actions\Action9\Params]
icon=STRING|"1"
msg0=STRING|"file name: {filename}"
msg2=STRING|"date: {dt}"
msg3=STRING|"Report No: {ReportNo}"
msg4=STRING|"Project No: {ProjectNo}"
msgcount=STRING|"5"
playsound=STRING|"0"
showmessage=STRING|"1"


I tested it on folder contains such files:
20190606_SK37-0619-1_DECL632.pdf
20190606_SK38-0619-1_DECL632.pdf
20190608_SK66-0619-1_DECL632.pdf
20190609_SK39-0619-1_DECL632.pdf


Thank you your suggestion.
I saved the above text into tsk file and import to robotask, but no action list is shown for this task even I enabled.
Anything I missed?
danger.ngai
 
Posts: 7
Joined: Thu Jun 13, 2019 4:31 am

Re: How to get the top file name and insert into variables?

Postby Oleg » Fri Jun 21, 2019 12:54 pm

I can save and import without problem
see video: https://youtu.be/U36wKHPELLM
Oleg Yershov
Oleg
Site Admin
 
Posts: 2455
Joined: Thu Jan 01, 1970 1:00 am

Re: How to get the top file name and insert into variables?

Postby danger.ngai » Mon Jun 24, 2019 3:29 am

Oleg wrote:I can save and import without problem
see video: https://youtu.be/U36wKHPELLM

Thank you. Now it work.

But 1 question, I need to scan and upload the file one by one.
So if the folder contains more than 1 pdf, this loop will only store the last one as variables.

E.g.
20190606_SK37-0619-1_DECL630.pdf
20190606_SK38-0619-1_DECL631.pdf
20190608_SK66-0619-1_DECL632.pdf
20190609_SK39-0619-1_DECL633.pdf

The 3 variables only record "20190609_SK39-0619-1_DECL633.pdf"
Can the file loop only scan one file?
danger.ngai
 
Posts: 7
Joined: Thu Jun 13, 2019 4:31 am

Re: How to get the top file name and insert into variables?

Postby Oleg » Mon Jun 24, 2019 10:25 am

You have to upload file within the loop if you want to upload file one-by-one.
That is between step #2 (file loop) and #13 (end loop)

Of course variables contain only last value after the loop.
Oleg Yershov
Oleg
Site Admin
 
Posts: 2455
Joined: Thu Jan 01, 1970 1:00 am

Re: How to get the top file name and insert into variables?

Postby danger.ngai » Thu Jun 27, 2019 3:49 am

Oleg wrote:You have to upload file within the loop if you want to upload file one-by-one.
That is between step #2 (file loop) and #13 (end loop)

Of course variables contain only last value after the loop.


thank you.
I would like to change the date format from 20190619 into 06-19-2019
however, the expression like below:
(^\d{2}-\d{2}-\d{4}$)_([^_]+)_([^\.]+)\.pdf
failed to match the result, anything I wrong?
danger.ngai
 
Posts: 7
Joined: Thu Jun 13, 2019 4:31 am

Re: How to get the top file name and insert into variables?

Postby Oleg » Thu Jun 27, 2019 3:57 pm

anything I wrong?

Unfortunately everything

Use the expression to format date from foremat yyyymmdd to your format (mm-dd-yyyy):
{DateTimeToFormat({FormatToDateTime({expr(1)},yyyymmdd)},mm-dd-yyyy)}

Also look at my corrected example
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1040932817
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task565"
Hide=INTEGER|0
ID=INTEGER|-1724333428
LogOnAsUser=INTEGER|1
Name=STRING|"Parse file name"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PDFFOLDER"" with value ""D:\incoming\pdf"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"PDFFOLDER"
varvalue=STRING|"D:\incoming\pdf"

[Actions\Action10]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""file name: {filename}"""
Params=FOLDER

[Actions\Action10\Params]
icon=STRING|"1"
msg0=STRING|"file name: {filename}"
msg2=STRING|"unformatted date: {dt}"
msg3=STRING|"formatted date: {dt1}"
msg4=STRING|"Report No: {ReportNo}"
msg5=STRING|"Project No: {ProjectNo}"
msgcount=STRING|"6"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action11]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action12]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""The name {fileName} does not match!"""
Params=FOLDER

[Actions\Action12\Params]
icon=STRING|"3"
msg0=STRING|"The name {fileName} does not match!"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action13]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action14]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action2]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action2\Params]
createmode=STRING|"1"
date1=STRING|"20190617"
date2=STRING|"20190617"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{PDFFolder}\*.pdf"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER

[Actions\Action3\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{FileName}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?i)(\d+)_([^_]+)_([^\.]+)\.pdf"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"match"

[Actions\Action4]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action4\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{match}"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{expr}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"{expr}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""DT"" with value ""{expr(1)}"""
Params=FOLDER

[Actions\Action6\Params]
expand=STRING|"1"
varname=STRING|"DT"
varvalue=STRING|"{expr(1)}"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""DT1"" with value ""{DateTimeToFormat({FormatToDateTime({expr(1)},yyyymmdd)},mm-dd-yyyy)}"""
Params=FOLDER

[Actions\Action7\Params]
expand=STRING|"1"
varname=STRING|"DT1"
varvalue=STRING|"{DateTimeToFormat({FormatToDateTime({expr(1)},yyyymmdd)},mm-dd-yyyy)}"

[Actions\Action8]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""REPORTNO"" with value ""{expr(2)}"""
Params=FOLDER

[Actions\Action8\Params]
expand=STRING|"1"
varname=STRING|"REPORTNO"
varvalue=STRING|"{expr(2)}"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PROJECTNO"" with value ""{expr(3)}"""
Params=FOLDER

[Actions\Action9\Params]
expand=STRING|"1"
varname=STRING|"PROJECTNO"
varvalue=STRING|"{expr(3)}"
Oleg Yershov
Oleg
Site Admin
 
Posts: 2455
Joined: Thu Jan 01, 1970 1:00 am

Re: How to get the top file name and insert into variables?

Postby danger.ngai » Wed Jul 03, 2019 4:31 am

Oleg wrote:
anything I wrong?

Unfortunately everything

Use the expression to format date from foremat yyyymmdd to your format (mm-dd-yyyy):
{DateTimeToFormat({FormatToDateTime({expr(1)},yyyymmdd)},mm-dd-yyyy)}

Also look at my corrected example
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1040932817
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task565"
Hide=INTEGER|0
ID=INTEGER|-1724333428
LogOnAsUser=INTEGER|1
Name=STRING|"Parse file name"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PDFFOLDER"" with value ""D:\incoming\pdf"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"PDFFOLDER"
varvalue=STRING|"D:\incoming\pdf"

[Actions\Action10]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""file name: {filename}"""
Params=FOLDER

[Actions\Action10\Params]
icon=STRING|"1"
msg0=STRING|"file name: {filename}"
msg2=STRING|"unformatted date: {dt}"
msg3=STRING|"formatted date: {dt1}"
msg4=STRING|"Report No: {ReportNo}"
msg5=STRING|"Project No: {ProjectNo}"
msgcount=STRING|"6"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action11]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action12]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""The name {fileName} does not match!"""
Params=FOLDER

[Actions\Action12\Params]
icon=STRING|"3"
msg0=STRING|"The name {fileName} does not match!"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action13]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action14]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action2]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action2\Params]
createmode=STRING|"1"
date1=STRING|"20190617"
date2=STRING|"20190617"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{PDFFolder}\*.pdf"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER

[Actions\Action3\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{FileName}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?i)(\d+)_([^_]+)_([^\.]+)\.pdf"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"match"

[Actions\Action4]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action4\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{match}"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{expr}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"{expr}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""DT"" with value ""{expr(1)}"""
Params=FOLDER

[Actions\Action6\Params]
expand=STRING|"1"
varname=STRING|"DT"
varvalue=STRING|"{expr(1)}"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""DT1"" with value ""{DateTimeToFormat({FormatToDateTime({expr(1)},yyyymmdd)},mm-dd-yyyy)}"""
Params=FOLDER

[Actions\Action7\Params]
expand=STRING|"1"
varname=STRING|"DT1"
varvalue=STRING|"{DateTimeToFormat({FormatToDateTime({expr(1)},yyyymmdd)},mm-dd-yyyy)}"

[Actions\Action8]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""REPORTNO"" with value ""{expr(2)}"""
Params=FOLDER

[Actions\Action8\Params]
expand=STRING|"1"
varname=STRING|"REPORTNO"
varvalue=STRING|"{expr(2)}"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PROJECTNO"" with value ""{expr(3)}"""
Params=FOLDER

[Actions\Action9\Params]
expand=STRING|"1"
varname=STRING|"PROJECTNO"
varvalue=STRING|"{expr(3)}"

Thanks for your help!
Robatask is really functional and interesting
danger.ngai
 
Posts: 7
Joined: Thu Jun 13, 2019 4:31 am


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 11 guests