Convert XML Count Settings to DAT Count setiings ?

MitchSharpe
Member
Posts: 26
Joined: Mon Sep 26, 2011 4:49 am

Convert XML Count Settings to DAT Count setiings ?

Post 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
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Convert XML Count Settings to DAT Count setiings ?

Post by dkelly »

Did you store the count using setGlobalData() function?
MitchSharpe
Member
Posts: 26
Joined: Mon Sep 26, 2011 4:49 am

Convert XML Count Settings to DAT Count setiings ?

Post 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
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Convert XML Count Settings to DAT Count setiings ?

Post 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();


MitchSharpe
Member
Posts: 26
Joined: Mon Sep 26, 2011 4:49 am

Convert XML Count Settings to DAT Count setiings ?

Post 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
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Convert XML Count Settings to DAT Count setiings ?

Post 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);
MitchSharpe
Member
Posts: 26
Joined: Mon Sep 26, 2011 4:49 am

Convert XML Count Settings to DAT Count setiings ?

Post by MitchSharpe »

Thank you ...
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Convert XML Count Settings to DAT Count setiings ?

Post 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"
MitchSharpe
Member
Posts: 26
Joined: Mon Sep 26, 2011 4:49 am

Convert XML Count Settings to DAT Count setiings ?

Post 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 !
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Convert XML Count Settings to DAT Count setiings ?

Post by dkelly »

because they used the same method I original proposed, global data.
MitchSharpe
Member
Posts: 26
Joined: Mon Sep 26, 2011 4:49 am

Convert XML Count Settings to DAT Count setiings ?

Post by MitchSharpe »

Fair enough then Global Data it is !



Thanks again !
MitchSharpe
Member
Posts: 26
Joined: Mon Sep 26, 2011 4:49 am

Convert XML Count Settings to DAT Count setiings ?

Post 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 ?
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Convert XML Count Settings to DAT Count setiings ?

Post 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);

}
MitchSharpe
Member
Posts: 26
Joined: Mon Sep 26, 2011 4:49 am

Convert XML Count Settings to DAT Count setiings ?

Post by MitchSharpe »

Thank you DKelly, I started looking down that path of a new flow, with your help I will continue !
MitchSharpe
Member
Posts: 26
Joined: Mon Sep 26, 2011 4:49 am

Convert XML Count Settings to DAT Count setiings ?

Post 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 ... !
Post Reply