How to extract characters from a file name?

Discuss RoboTask here
Post Reply
ntesla
Posts: 4
Joined: Wed May 14, 2014 6:18 am

How to extract characters from a file name?

Post by ntesla »

Hi

I'm new to Robotask but I'm loving it. Great program! I've been telling everyone I know about it!

There's just one things I can't figure out. If Robotask identifies a file (eg, 'qwk*.txt') is there a way to extract the characters that the wildcard represents and assign them to a variable?

If you can provide any insights I would be very grateful.

Thank you in advance
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: How to extract characters from a file name?

Post by Oleg »

Do you want collect all filenames by mask?
You can use File Loop.
See example below:

Code: Select all

 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task881"
Hide=INTEGER|0
ID=INTEGER|1152080012
LogOnAsUser=INTEGER|1
Name=STRING|"Collect files 1"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""MASK"" with value ""qwk*.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"MASK"
varvalue=STRING|"qwk*.txt"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""FILENAME"" with value """""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"FILENAME"

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

[Actions\Action3\Params]
createmode=STRING|"1"
date1=STRING|"20140514"
date2=STRING|"20140514"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"d:\incoming\{mask}"
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|"1"

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

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

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

Also see Search for Files action
See another example below:

Code: Select all

 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task884"
Hide=INTEGER|0
ID=INTEGER|985721994
LogOnAsUser=INTEGER|1
Name=STRING|"Collect files 2"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""MASK"" with value ""qwk*.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"MASK"
varvalue=STRING|"qwk*.txt"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""FILENAMES"" with value """""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"FILENAMES"

[Actions\Action3]
ActionID=STRING|"A_FILE_SEARCH"
Enabled=INTEGER|-1
Name=STRING|"Create File List (variable: FileNames)"
Params=FOLDER

[Actions\Action3\Params]
After=STRING|"0"
aftercount=STRING|"0"
AfterLine=STRING|"0"
Before=STRING|"0"
beforecount=STRING|"0"
BeforeLine=STRING|"0"
createmode=STRING|"1"
date1=STRING|"20140514"
date2=STRING|"20140514"
destvar=STRING|"FileNames"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"d:\incoming\{mask}"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savetofile=STRING|"0"
savetovar=STRING|"1"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"0"
WithoutPath=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{FileNames}"""
Params=FOLDER

[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"{FileNames}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
Next you can process the list in Text loop
Oleg Yershov
ntesla
Posts: 4
Joined: Wed May 14, 2014 6:18 am

Re: How to extract characters from a file name?

Post by ntesla »

Many thanks. I'll look into it.
Post Reply