Page 1 of 2
Convert XML Count Settings to DAT Count setiings ?
Posted: Thu May 22, 2014 3:31 am
by MitchSharpe
Hello all,
I am transitioning from a Switch 11 machine to a Switch 12 machine and I have an issue with 1 flow.
I have a flow which renames files uploaded to a website and numbers each file counting up each time. As I need to retain the last remembered number I thought of trying moving the Count Setting from the old to new version but by my observation the new count setting preference is a DAT file ...
And moving the XML into the settings folder did not pick it up - of course ...
Any idea how I can take the existing info and get it into the DAT file ?
Thanks for any suggestions !
Mitch
Convert XML Count Settings to DAT Count setiings ?
Posted: Thu May 22, 2014 3:19 pm
by dkelly
Did you store the count using setGlobalData() function?
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 1:00 am
by MitchSharpe
Please elaborate ? (ie: No, Im not aware of that function, will look it up in the manual ... ) and try to work it out.
But in the mean time Ive upgraded the sw 11 to sw 12 on the old mac and of course it continues numbering correctly. Exporting the flow and importing to the new machine I start at the base number !
Mitch
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 1:49 am
by dkelly
Are you talking about the Rename Job element? It doesn't store a count; rather, it just attempts to avoid a name collision by adding a unique number to the end of a filename. If you enable debug logging in Preferences you will see messages like "Resolving name collision for file ..." and Name after resolving ..."
A simple script could store a counter in the global dataset which is available to any job. It gets incremented each time the script is called; typically once per job.
Use it in a rename "add suffix" properties as a script expression:
var cnt = s.getGlobalData("mycounter");
if (cnt == "") cnt = 1; else cnt = parseInt(cnt,10)+1;
s.setGlobalData("mycounter", cnt);
cnt.toString();
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 2:01 am
by MitchSharpe
Correct rename job ... Using - BlahBlah2[Switch.Counter:Width="4",Space=norm] - as variable. Looking at flow pref yes resolve collisions is "Add suffix ..." Pattern _count ...
I will look into your suggestion and see if I can get it to work for me ... I need it to start from a certain number now though ! Im sure theres a way to add a start count ?
Thank you for your help !
Mitch
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 2:05 am
by dkelly
Run this script once to set initial value (1 less than you want 1st job to be) changing 123 to your value.
s.setGlobalData("mycounter", 123);
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 2:07 am
by MitchSharpe
Thank you ...
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 2:19 am
by dkelly
MitchSharpe wrote: Correct rename job ... Using - BlahBlah2[Switch.Counter:Width="4",Space=norm]
ah, Switch.Counter. I've not explored how that's stored... yet
The counter is stored in the support file UserGlobalData.xml
00DYV
32
Change the value of "Counter"
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 2:24 am
by MitchSharpe
That sounds correct that was the other "preference" file changed when a file was renamed ... Why would they put the data in the "CountSettings" file like I would have expected !
Im wondering what would happen if I moved the UserGlobalData.xml file from one to the other machine ... If I had of done it earlier in the machine swap I probably would have gotten away with it !
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 2:29 am
by dkelly
because they used the same method I original proposed, global data.
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 2:45 am
by MitchSharpe
Fair enough then Global Data it is !
Thanks again !
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 6:47 am
by MitchSharpe
I have to show my inexperience here ... I am after all a Mac expert not a Switch expert !
How do I run that single script ... s.setGlobalData("mycounter", 123);
I take it it's not a Unix command, and I am not aware of any way to run a script other than make a workflow and tell it to run a script ?
Convert XML Count Settings to DAT Count setiings ?
Posted: Fri May 23, 2014 2:24 pm
by dkelly
Create a simple flow with a Scripted element containing:
function timerFired(s : Switch )
{
s.log(2, "Setting initial value for counter");
s.setGlobalData("mycounter", 123);
}
Convert XML Count Settings to DAT Count setiings ?
Posted: Tue May 27, 2014 2:55 am
by MitchSharpe
Thank you DKelly, I started looking down that path of a new flow, with your help I will continue !
Convert XML Count Settings to DAT Count setiings ?
Posted: Tue May 27, 2014 6:21 am
by MitchSharpe
Well I gave setting the GlobalData a counter value but got this thrown back at me ...
Error in line 4 of script : Error. No matching slot found_ available overloads are:
void Switch::setGlobalData(QString_QString_QString_bool)
void Switch::setGlobalData(QString_QString_QString)
I take it I have missed something ? You said simple flow so I had a folder going to a script element with that info in a SwitchScript ... I take it there might have been something in the script I needed to set, I'll check that out shortly ...
Thanks again for your assistance ...
Then I need to work out how to change the Counting from Collisions to actual naming ... !