delete a piece of string with wildcards?

Discuss RoboTask here
Post Reply
pancakegh
Posts: 15
Joined: Mon Feb 16, 2015 10:21 am

delete a piece of string with wildcards?

Post by pancakegh »

I have a main folder with subfolders wich contain another subfolder with in the last folder a jpg image file named " ***.**.****.jpg " the image files have different names

I need to upload the subfolders in the main folder to my FTP wich has the same structure as the local main folder.
Synchronizing the folders takes WAY to much time because the FTP directory contains an enormous amount of .jpg files already.
I want to individually upload every single image in my local folder to the corresponding FTP folder.

I made a simple file loop wich extracts a variable called " {oldfilename} " for the local image directory. and in the file loop it changes the "{oldfilename}" into "{ftplocatie}" wich will be the ftp directory.

here's an example of the {oldfilename}: C:\Users\webdesign\Desktop\temp\hires\2\401.90.0012.jpg

Here's an example of the {ftplocatie}: \products\hires\2\401.90.0012.jpg

All I need is to trim the " 401.90.0012.jpg " part.

But how do I delete an "X" amount of characters at the end of a string?

I can't seem to find and replace the 401.90.0012.jpg part with wildcards ***.**.****.jpg to nothing.


Here's my task:

Code: Select all


[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task13"
Hide=INTEGER|0
ID=INTEGER|426203686
LogOnAsUser=INTEGER|1
Name=STRING|"File Loop..."
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|0
WriteGeneralLog=INTEGER|0

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

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

[Actions\Action1\Params]
createmode=STRING|"1"
date1=STRING|"20100105"
date2=STRING|"20100105"
destvar=STRING|"OLDFILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"C:\Users\webdesign\Desktop\temp\*.jpg"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

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

[Actions\Action2\Params]
case=STRING|"0"
from=STRING|"30"
search=STRING|"\"
source=STRING|"{OldFileName}"
variable=STRING|"APos"

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

[Actions\Action3\Params]
amount=STRING|"{APos}"
from=STRING|"1"
source=STRING|"{OldFileName}"
variable=STRING|"NewFileName"

[Actions\Action4]
ActionID=STRING|"A_STR_INSERT"
Enabled=INTEGER|-1
Name=STRING|"STR Insert"
Params=FOLDER

[Actions\Action4\Params]
insert=STRING|"\products\"
pos=STRING|"1"
source=STRING|"{newfilename}"
variable=STRING|"ftplocatie"

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

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"{oldfilename}"
msg2=STRING|"{ftplocatie}"
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: delete a piece of string with wildcards?

Post by Oleg »

Use {ExtractFilePath()} variable.

See my example below. Save the text of task into a file and use menu Task->Import to import 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|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1111"
Hide=INTEGER|0
ID=INTEGER|1644715928
LogOnAsUser=INTEGER|1
Name=STRING|"trim the end"
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

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""SOUR"" with value ""\products\hires\2\401.90.0012.jpg"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"SOUR"
varvalue=STRING|"\products\hires\2\401.90.0012.jpg"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""DEST"" with value ""{ExtractFilePath({sour})}\"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"1"
varname=STRING|"DEST"
varvalue=STRING|"{ExtractFilePath({sour})}\"

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

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"{sour}"
msg1=STRING|"{dest}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
Post Reply