{ExtractFileName({variable})} issue

Discuss RoboTask here
Post Reply
msbtrp23
Posts: 12
Joined: Mon Sep 03, 2012 7:37 am

{ExtractFileName({variable})} issue

Post by msbtrp23 »

When I tried to get the file name without path in variable it wouldn't save it as I planned and saves it like "{ExtractFileName({variable})} " but in another task it works fine! can you help me with that situation ? Here is the routine:-----------------------------------------;*****************************;* RoboTask Task file;* Do not edit in text editor!;***************************** [Root]ActionAfterRun=INTEGER|0Actions=FOLDERAutomat=INTEGER|-1CatID=INTEGER|0Comment=STRINGLISTContinueOnError=INTEGER|0Events=FOLDERExternalName=STRING|"Task4"Hide=INTEGER|0ID=INTEGER|734892539LogOnAsUser=INTEGER|1Name=STRING|"Experimental"OnErrorTaskID=INTEGER|0Priority=INTEGER|3RunOnClose=INTEGER|0RunOnStartup=INTEGER|0ToLog=INTEGER|3WriteGeneralLog=INTEGER|0[Actions]Action1=FOLDERAction2=FOLDERAction3=FOLDERAction4=FOLDERAction5=FOLDERAction6=FOLDER[Actions\Action1]ActionID=STRING|"A_LOOP_TEXT"Enabled=INTEGER|-1Name=STRING|"Text Loop"Params=FOLDER[Actions\Action1\Params]destvar=STRING|"FILETOPROCESS"file=STRING|"C:\ListOfNewFiles.tmp"linecount=STRING|"0"sourcetext=STRING|"0"[Actions\Action2]ActionID=STRING|"A_VARIABLES_SET"Enabled=INTEGER|-1Name=STRING|"Set variable ""Q"" with value ""{ExtractFileName({FiletoProcess})}"""Params=FOLDER[Actions\Action2\Params]expand=STRING|"1"varname=STRING|"Q"varvalue=STRING|"{ExtractFileName({FiletoProcess})}"[Actions\Action3]ActionID=STRING|"A_GENERAL_RUN_PROG"Enabled=INTEGER|-1Name=STRING|"Run ""ARJ.EXE e {FILETOPROCESS} E:\temp\work\"""Params=FOLDER[Actions\Action3\Params]ifnonzero=STRING|"0"params=STRING|"e {FILETOPROCESS} E:\temp\work\"program=STRING|"E:\TEMP\ARJ.EXE"runas=STRING|"3"wait=STRING|"0"[Actions\Action4]ActionID=STRING|"A_DIALOG_MESSAGE"Enabled=INTEGER|-1Name=STRING|"Show ""{Q}"""Params=FOLDER[Actions\Action4\Params]icon=STRING|"1"msg0=STRING|"{Q}"msgcount=STRING|"1"playsound=STRING|"0"showmessage=STRING|"1"[Actions\Action5]ActionID=STRING|"A_FILE_COPY"Enabled=INTEGER|0Name=STRING|"Copy/Move File"Params=FOLDER[Actions\Action5\Params]destdir=STRING|"e:\temp\archive"f_count=STRING|"1"file0=STRING|"{FILETOPROCESS}"hidden=STRING|"1"ifexists=STRING|"1"move=STRING|"1"subdir=STRING|"0"system=STRING|"1"[Actions\Action6]ActionID=STRING|"A_LOOP_END"Enabled=INTEGER|-1Name=STRING|"End Loop"[Events]Event1=FOLDER[Events\Event1]Enabled=INTEGER|-1EventID=STRING|"E_FILE_MONITOR"Params=FOLDERUnigueID=INTEGER|29667590[Events\Event1\Params]chg=STRING|"0"chga=STRING|"1"chgsl=STRING|"1"chgsm=STRING|"1"chgtl=STRING|"1"chgtm=STRING|"1"del=STRING|"0" excmask=STRING|"*.xls,*.doc,*.rar,*.arj,*.ido,*.pdf,*.jpg,*. tif,*.txt,"folder1=STRING|"e:\temp\inbox"foldercount=STRING|"1"id=STRING|"KW6UQW5VS" incmask=STRING|"*.120,*.069,*.073,*.140,*.194,*.206,*.231,*. 264,*.358,*.373,*.411,*.416,*.417,*.539,*.581,*.625,*.631,*. 904,*.958,*.963,*.969,*.971,*.972,*.004,*.021,*.027" interval=STRING|"3"listmode=STRING|"2"mon_files=STRING|"1"mon_folders=STRING|"0"new=STRING|"1"newlist=STRING|"C:\ListOfNewFiles.tmp"saveresults=STRING|"1"subfolders1=STRING|"0"
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

{ExtractFileName({variable})} issue

Post by Oleg »

I've just tried your task without changing.
It's working.

I use such text file:
D:\incoming\2010 AUA.txt
D:\incoming\commatext.txt
D:\incoming\ComposedFile.txt
D:\incoming\sample.txt
D:\incoming\sample1.txt
D:\incoming\sample2.txt
D:\incoming\test.txt

the task extracts filenames correctly in the loop:
2010 AUA.txt
commatext.txt
ComposedFile.txt
sample.txt
sample1.txt
sample2.txt
test.txt
Last edited by Oleg on Thu Nov 29, 2012 3:02 pm, edited 1 time in total.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

{ExtractFileName({variable})} issue

Post by Oleg »

Also I recommend to declare variables FileToProcess and Q as local variables.
See on screenshot below:

msbtrp23
Posts: 12
Joined: Mon Sep 03, 2012 7:37 am

{ExtractFileName({variable})} issue

Post by msbtrp23 »

but I keep getting this in Q variable:
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

{ExtractFileName({variable})} issue

Post by Oleg »

It seems your files contains symbol "(" in names. Correct?
Like this:
C:\root\src\(testFile.txt

Superfluous parenthesis breaks the syntax of expression. So RoboTask can't calculate the result.

You should replace "(" and ")" in names to other symbols.
Lets replace ( with [[ and ) with ]]
Next we can calculate the result and make inverse replacements.
See example below. If you disable all "Str Replace" steps you will get your problem exactly.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|345474660
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task83"
Hide=INTEGER|0
ID=INTEGER|1600483830
LogOnAsUser=INTEGER|1
Name=STRING|"Create local variable ""FILENAME"" with value ""C:\root\src\(testFile.txt""..."
OnErrorTaskID=INTEGER|0
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
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""FILENAME"" with value ""C:\root\src\(testFile.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"FILENAME"
varvalue=STRING|"C:\root\src\(testFile.txt"

[Actions\Action2]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action2\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"[["
source=STRING|"{FileName}"
substring=STRING|"("
variable=STRING|"FileName"

[Actions\Action3]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action3\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"]]"
source=STRING|"{FileName}"
substring=STRING|")"
variable=STRING|"FileName"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""Q"" with value ""{ExtractFileName({Filename})}"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"1"
varkind=STRING|"1"
varname=STRING|"Q"
varvalue=STRING|"{ExtractFileName({Filename})}"

[Actions\Action5]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action5\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"("
source=STRING|"{FileName}"
substring=STRING|"[["
variable=STRING|"FileName"

[Actions\Action6]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action6\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|")"
source=STRING|"{FileName}"
substring=STRING|"]]"
variable=STRING|"FileName"

[Actions\Action7]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action7\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"("
source=STRING|"{q}"
substring=STRING|"[["
variable=STRING|"q"

[Actions\Action8]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action8\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|")"
source=STRING|"{q}"
substring=STRING|"]]"
variable=STRING|"q"

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

[Actions\Action9\Params]
icon=STRING|"1"
msg0=STRING|"{filename}"
msg1=STRING|"{q}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
msbtrp23
Posts: 12
Joined: Mon Sep 03, 2012 7:37 am

{ExtractFileName({variable})} issue

Post by msbtrp23 »

Great solution! Thanks! "(" was the problem.
Post Reply