Page 1 of 1

numsuffix for renameitem broken

Posted: 10 Jun 2016 17:57
by tiago
It simply doesn't produce any result no matter what scenario it finds.

Re: numsuffix for renameitem broken

Posted: 10 Jun 2016 19:23
by tiago
So I left it alone for some minutes, went back and it started working.

:eh:

The only problem is it does this (top is newest; after a series of 4 operations):

Default_01_03.xml
Default_01_02.xml
Default_01_01.xml
Default_01.xml

instead of expected:
Default_04.xml
Default_03.xml
Default_02.xml
Default_01.xml

for a base file "Default.xml".

Pertinent command:
renameitem("Default_01.xml", "$xml", , "_01");

-because renameitem("Default.xml", "$xml", , "_01"); results null.

Re: numsuffix for renameitem broken

Posted: 11 Jun 2016 11:17
by admin
(Moved to "Tips & Tricks, Questions & Answer" because it is a usage question.)

I'm not sure what you want to achieve, but SC renameitem probably isn't the right way to go. The Help tells me that it is meant to only rename *one* item.

Re: numsuffix for renameitem broken

Posted: 11 Jun 2016 13:20
by tiago
Numsuffix seems to not like finding a basename, admin, ie: it demands a first suffix to start appending more on top of it.
Trying
renameitem("Default.xml", "$xml", , "_01");

on $xml = "Default.xml" produces nothing.

So I'm forced to use
renameitem("Default_01.xml", "$xml", , "_01");

which then produces exotic Default_01_01.xml, Default_01_02.xml, Default_01_03.xml... files, when they should be simply
Default_01.xml, Default_02.xml, Default_03.xml.

I see no logical reason to be forced to such behavior.

Re: numsuffix for renameitem broken

Posted: 13 Jun 2016 09:22
by admin
Works as advertised and makes sense to me.

What do you want to achieve? Input? Output?

Re: numsuffix for renameitem broken

Posted: 13 Jun 2016 13:37
by tiago
All due respect, the advertised behavior would be

renameitem("Default.xml", "$xml", , "_01");

producing "Default_01.xml" if target file ($xml) is "...\Default.xml", as there's no remark at all for the described case. Therefore the sequence would be
Default_02.xml
Default_03.xml
Default_04.xml
and so on, if and when required - which is the reason why numsufiix exists. Of course it's assumed that another "Default.xml" will be there when renameitem is executed again.

Re: numsuffix for renameitem broken

Posted: 13 Jun 2016 13:46
by highend
It makes sense that it should work this way, even if renameitem references the source file as it's destination file
because logically the destination file already exists -> Hence rename the current one.

Re: numsuffix for renameitem broken

Posted: 13 Jun 2016 17:15
by admin
I don't agree, but I will add a flag to make it work as desired in this thread.

Re: numsuffix for renameitem broken

Posted: 14 Jun 2016 14:43
by tiago
Can't test the change for the time being but... thanks for listening! :beer:

Re: numsuffix for renameitem broken

Posted: 14 Jun 2016 14:48
by highend
It works as expected with flags = 16...