uniqueFileName()

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

Locked
plasticmagnet
Posts: 19
Joined: 14 Sep 2013 18:41

uniqueFileName()

Post by plasticmagnet » 01 Aug 2014 08:43

Would be nice if you could add an function that creates unique file names to prevent overwriting.
(file(1).txt , file(2).txt...)

Or maybe even better to add it as option to 'Write to File' action.

Thank you.

plasticmagnet
Posts: 19
Joined: 14 Sep 2013 18:41

Re: uniqueFileName()

Post by plasticmagnet » 09 Nov 2014 01:30

still no reply(?).. sry if request was nonsense.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: uniqueFileName()

Post by Martin » 10 Nov 2014 17:18

Sorry, no nonsense, I just usually don't have the time to reply to every feature request.

You could use a loop in a script and function existsFile to create a unique file name on your own.
Another option would be to include the date/time in the file name to avoid naming problems: file_{triggertime,dateformat,YYYYmmdd_HHmmss}.txt

Regards,
Martin

plasticmagnet
Posts: 19
Joined: 14 Sep 2013 18:41

Re: uniqueFileName()

Post by plasticmagnet » 12 Nov 2014 04:12

Thanks for answering.
I didnt actually realize we only need a few lines of code to cover this case.

saveTo = "/storage/emulated/0/file({i = convertNull(i, 1)}).txt";
while (existsFile(saveTo))
{ saveTo = "/storage/emulated/0/file({i = i + 1}).txt";
}

Thank you again.
MFG!

Locked