Page 1 of 2

Rename folders

Posted: Mon Jan 14, 2013 7:50 pm
by rice1973
Hello Oleg,

I need to rename folders.

eg "12532-123.10.236" has to become "123.10.236"
eg "1254-152.23.252" has to become "152.23.252"

Under is the task for renaming files like that. How can i
use it to rename the folders?

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1190029287
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task3"
Hide=INTEGER|0
ID=INTEGER|1601804429
LogOnAsUser=INTEGER|1
Name=STRING|"rename files"
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_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|"D:\3dmap\*.swf"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
subdirs=STRING|"0"
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|"1"
search=STRING|"-"
source=STRING|"{ExtractFileName({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|"{ExtractFileName({OldFileName})}"
variable=STRING|"NewFileName"

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

[Actions\Action4\Params]
case=STRING|"0"
mode=STRING|"0"
source=STRING|"{NewFileName}"
substring=STRING|"-000"
variable=STRING|"NewFileName"

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

[Actions\Action5\Params]
case=STRING|"0"
operator=STRING|"1"
type=STRING|"0"
value1=STRING|"{ExtractFileName({OldFileName})}"
value2=STRING|"{NewFileName}"

[Actions\Action6]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action6\Params]
message=STRING|"File {OldFileName} is renaming to
{NewFileName} ..."
type=STRING|"3"

[Actions\Action7]
ActionID=STRING|"A_FILE_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename File"
Params=FOLDER

[Actions\Action7\Params]
count=STRING|"1"
file0=STRING|"{OldFileName}"
ifexists=STRING|"0"
mask=STRING|"{NewFileName}"
subdirs=STRING|"0"

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

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

Rename folders

Posted: Tue Jan 15, 2013 7:13 am
by Oleg
You can't use this task without changes.
You should modify this task (or create new task and use this task as template):
- File loop mus be "By folders"
- It seems step #4 is superfluous
- Use "rename folder" instead of "rename files"

Rename folders

Posted: Tue Jan 15, 2013 10:55 am
by rice1973
Mmmh,

Almost good, but not working.

Can you look?

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task4"
Hide=INTEGER|0
ID=INTEGER|150137837
LogOnAsUser=INTEGER|1
Name=STRING|"rename folders 2"
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_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|"{NEWPATHNAME}"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"D:\3dmap\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"1"
subdirs=STRING|"0"
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|"1"
search=STRING|"-"
source=STRING|"{ExtractPathName({OldPathName})}"
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|"{ExtractPathName({OldPathName})}"
variable=STRING|"NewPathName"

[Actions\Action4]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER[Root]
item0003=STRINGLIST
item0004=STRINGLIST
item0005=STRINGLIST
item0006=STRINGLIST
item0007=STRINGLIST
item0008=STRINGLIST
item0009=STRINGLIST
item0010=STRINGLIST
item0011=STRINGLIST

[\item0003]
s1=[General]
s2=ActionId=A_LOOP_FILE
s3=Name=File Loop
s4=Enabled=-1
s5=[Params]
s6=searchkind=1
s7=filecount=1
s8=file0=D:\3dmap\*.*
s9=subdirs=0
s10=destvar={NEWPATHNAME}
s11=createmode=1
s12=date1=20100105
s13=date2=20100105
s14=DuringMonths=1
s15=DuringDays=1
s16=OlderMonths=1
s17=OlderDays=1
s18=DuringHours=1
s19=DuringMinutes=1
s20=OlderHours=1
s21=OlderMinutes=1
s22=WithoutPath=0
s23=savesize=0
s24=timesize=0

[\item0004]
s1=[General]
s2=ActionId=A_STR_POS
s3=Name=STR Pos
s4=Enabled=-1
s5=[Params]
s6=source={ExtractPathName({OldPathName})}
s7=search=-
s8=case=0
s9=from=1
s10=variable=APos

[\item0005]
s1=[General]
s2=ActionId=A_STR_DELETE
s3=Name=STR Delete
s4=Enabled=-1
s5=[Params]
s6=source={ExtractPathName({OldPathName})}
s7=from=1
s8=amount={APos}
s9=variable=NewPathName

[\item0006]
s1=[General]
s2=ActionId=A_STR_REPLACE
s3=Name=STR Replace
s4=Enabled=-1
s5=[Params]
s6=source={NewPathName}
s7=substring=-000
s8=case=0
s9=mode=0
s10=variable={NEWPATHNAME}

[\item0007]
s1=[General]
s2=ActionId=A_FLOW_IF
s3=Name=If Then
s4=Enabled=-1
s5=[Params]
s6=type=0
s7=value1={ExtractPatName({OldPathName})}
s8=operator=1
s9=value2={NewPathName}
s10=case=0

[\item0008]
s1=[General]
s2=ActionId=A_ROBOTASK_LOG
s3=Name=Log Message
s4=Enabled=-1
s5=[Params]
s6=message=File {OldPathName} is renaming to
{NEWPATHNAME} ...
s7=type=3

[\item0009]
s1=[General]
s2=ActionId=A_FILE_RENAME
s3=Name=Rename File
s4=Enabled=-1
s5=[Params]
s6=count=1
s7=file0={OldPathName}
s8=mask={NewPathName}
s9=subdirs=0
s10=ifexists=0

[\item0010]
s1=[General]
s2=ActionId=A_FLOW_ENDIF
s3=Name=End If
s4=Enabled=-1
s5=[Params]

[\item0011]
s1=[General]
s2=ActionId=A_LOOP_END
s3=Name=End Loop
s4=Enabled=-1
s5=[Params]



[Actions\Action4\Params]
case=STRING|"0"
mode=STRING|"0"
source=STRING|"{NewPathName}"
substring=STRING|"-000"
variable=STRING|"{NEWPATHNAME}"

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

[Actions\Action5\Params]
case=STRING|"0"
operator=STRING|"1"
type=STRING|"0"
value1=STRING|"{ExtractPatName({OldPathName})}"
value2=STRING|"{NewPathName}"

[Actions\Action6]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action6\Params]
message=STRING|"File {OldPathName} is renaming to
{NEWPATHNAME} ..."
type=STRING|"3"

[Actions\Action7]
ActionID=STRING|"A_FILE_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename File"
Params=FOLDER

[Actions\Action7\Params]
count=STRING|"1"
file0=STRING|"{OldPathName}"
ifexists=STRING|"0"
mask=STRING|"{NewPathName}"
subdirs=STRING|"0"

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

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

Rename folders

Posted: Tue Jan 15, 2013 11:21 am
by Oleg
I'm sorry this is a mishmash with text of the task and steps from clipboard...

Why do you use OldPathName variable in steps #2, 3, 5, 6, 7
I don't see where you assign some value to it

Maybe you want to save the value into OldPathName in step #1
Also see step #1. You do not need use braces "{}".
Write variable name only.

Rename folders

Posted: Tue Jan 15, 2013 12:37 pm
by rice1973
Hello Oleg,

See the Task you made for the files;

http://www.robotask.com/forum/forum_posts.asp?
TID=933&KW=rename+files

This one i need for folders.

Rename folders

Posted: Tue Jan 15, 2013 12:55 pm
by Oleg
See the example below:
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task69"
Hide=INTEGER|0
ID=INTEGER|150137837
LogOnAsUser=INTEGER|1
Name=STRING|"rename folders 3"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=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 ""OLDPATHNAME"" with value """""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"OLDPATHNAME"

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

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

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

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

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

[Actions\Action3\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"APOS"

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

[Actions\Action4\Params]
createmode=STRING|"1"
date1=STRING|"20100105"
date2=STRING|"20100105"
destvar=STRING|"OLDPATHNAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"D:\3dmap\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"1"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"0"

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

[Actions\Action5\Params]
case=STRING|"0"
from=STRING|"1"
search=STRING|"-"
source=STRING|"{ExtractPathName({OldPathName})}"
variable=STRING|"APos"

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

[Actions\Action6\Params]
amount=STRING|"{APos}"
from=STRING|"1"
source=STRING|"{ExtractPathName({OldPathName})}"
variable=STRING|"NewPathName"

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

[Actions\Action7\Params]
case=STRING|"0"
operator=STRING|"1"
type=STRING|"0"
value1=STRING|"{ExtractPatName({OldPathName})}"
value2=STRING|"{NewPathName}"

[Actions\Action8]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action8\Params]
message=STRING|"File {OldPathName} is renaming to {NewPathName}"
type=STRING|"3"

[Actions\Action9]
ActionID=STRING|"A_FOLDER_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename Folder ""{OldPathName}"""
Params=FOLDER

[Actions\Action9\Params]
folder=STRING|"{OldPathName}"
newfolder=STRING|"{NewPathName}"

Rename folders

Posted: Tue Jan 15, 2013 1:42 pm
by rice1973
Mmh, almost OK.

When i run the task it transforms "11444-388.30.025" in to
"388.30.025)}" ?? Strange isn't it?? :S

Rename folders

Posted: Tue Jan 15, 2013 1:59 pm
by Oleg
You should replace ExtractPathName to ExtractFileName everywhere
ExtractPathName - is nonexistent variable.

Or simply use the example below:
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task69"
Hide=INTEGER|0
ID=INTEGER|150137837
LogOnAsUser=INTEGER|1
Name=STRING|"rename folders 3"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=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 ""OLDPATHNAME"" with value """""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"OLDPATHNAME"

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

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

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

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

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

[Actions\Action3\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"APOS"

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

[Actions\Action4\Params]
createmode=STRING|"1"
date1=STRING|"20100105"
date2=STRING|"20100105"
destvar=STRING|"OLDPATHNAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"D:\3dmap\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"1"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"0"

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

[Actions\Action5\Params]
case=STRING|"0"
from=STRING|"1"
search=STRING|"-"
source=STRING|"{ExtractFileName({OldPathName})}"
variable=STRING|"APos"

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

[Actions\Action6\Params]
amount=STRING|"{APos}"
from=STRING|"1"
source=STRING|"{ExtractFileName({OldPathName})}"
variable=STRING|"NewPathName"

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

[Actions\Action7\Params]
case=STRING|"0"
operator=STRING|"1"
type=STRING|"0"
value1=STRING|"{ExtractFileName({OldPathName})}"
value2=STRING|"{NewPathName}"

[Actions\Action8]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action8\Params]
message=STRING|"File {OldPathName} is renaming to {NewPathName}"
type=STRING|"3"

[Actions\Action9]
ActionID=STRING|"A_FOLDER_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename Folder ""{OldPathName}"""
Params=FOLDER

[Actions\Action9\Params]
folder=STRING|"{OldPathName}"
newfolder=STRING|"{NewPathName}"

Rename folders

Posted: Tue Jan 15, 2013 2:22 pm
by rice1973
Thanx!!

Rename folders

Posted: Tue Jan 15, 2013 2:39 pm
by rice1973
Oeps, to early..

In the mainfolder eg "11641-286.65.001"
is a subfolder "Images" and in that folder the is another
subfolder "11641-286.65.001" that also has to be renamed
to "286.65.001"

So original structure is "11641-286.65.001/Images/11641-
286.65.001" has to become "286.65.001/Images/286.65.001"

The Include Subfolders in File Loop does
not work.

I think that is not working because of Create local
variable

Any solution?