File rotation in the directory

Post your questions and help other users.

Moderator: Martin

Post Reply
takehito
Posts: 5
Joined: 17 Sep 2014 11:53

File rotation in the directory

Post by takehito » 17 Sep 2014 12:17

Triggers run in 0:00 AM every day at the specified time

What can I do to the processing number of files, such as to avoid 5 or more at all times the number of files in a directory called "/storage/emulated/0/sample" will delete the old files in the case of 5 or more?

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

Re: File rotation in the directory

Post by Martin » 17 Sep 2014 16:54

Hi,

You could use an action Init Variable File List to store all files with a certain name in a list and then use action Delete Files to delete some of the files.

Regards,
Martin

takehito
Posts: 5
Joined: 17 Sep 2014 11:53

Re: File rotation in the directory

Post by takehito » 18 Sep 2014 01:09

I tried to set up in this way, but it does not always work as I think.

Step 1
Action: Init Variable File List
Variable: files
File Pattern: /storage/emulated/0/sample/*

Step 2
Action: Script
Script:
listlength = length(files);
if (listlength > 5)
{
removeElement(files, listlength - 1);
}

Step 3
Condition: Expression
Expression:
length(files) > 5

Step 4
Step 3 If the True
Action: Delete Files
Files: {files, listformat, comma}


When it is this Flow, and will not be operational files of 6 th until a generation.
All from being removed, leaving a single new file file 6 th is generated.

To make an operation to remove one old file file of 6 th is generated it, in Step3 and Step2, I want you to tell me should I describe what the script.

Post Reply