open list file

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

Moderator: Martin

Locked
farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

open list file

Post by farshadmo368 » 01 Jun 2018 09:42

hi,
I want to open 1,000 pdf files with app wps office + pdf .

open 1.pdf Action
2 seconds sleep
open 2.pdf The same action
2 seconds sleep
open 3.pdf The same action
.2 seconds sleep
.
.
.
.open 999.pdf the same action
2 seconds sleep
open 1000.pdf The same action

Their tuning is boring
Is there a good way?
please send answer or flow to my email or Here
farshadmo68@gmail.com

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: open list file

Post by Desmanto » 01 Jun 2018 13:10

This is what you have asked in several other thread. I will just answer it here.

I don't use WPS office, but adobe reader. I think WPS should have the same viewer activity, so below method should work too.

You will need to
init the file list of the folder
Find out the pdf files only and convert it to URI format
Loop open the pdf files.

Action 1 : Init Variable File List
Variables : files
File pattern : /storage/emulated/0/Documents/* >> change this to your folder which contain the 1000 pdf files

Action 2 : Script
You will need to check the file ending and and add them to the list. Need to encodeURL and concatenate the file:///

Code: Select all

pdf = newList();
for(i in files)
{
  if(endsWith(i, "pdf"))
    addElement(pdf, "file:///" + replace(encodeURL(i), "%2F", "/"))
}
index = 0;
len = length(pdf);
The index is prepared for the loop. len is the maximum loop

Action 3 : Start Activity
Action : android.intent.action.VIEW
Data URI : {pdf[index]}
Explicit Component : Check
Package Name : com.adobe.reader
Class Name : com.adobe.reader.AdobeReader
Both the package name need to be changed to the WPS package name and the viewer class name. I can't help you with this one, try it by yourself until you get the correct class name.

i don't know what you mean by same action, so I just skip to sleep.
Action 4 : Sleep 5s (or how many you need)

Condition 1 :

Code: Select all

if(index < len-1)
{
  index = index + 1;
  return true;
}
else return false;
This will check if the index is bigger than the number of pdf files. If no, increment the index and loop again. If yes, then stop the flow.
True : goes back to Action 3 : Start Activity.
Loop pdf.png
Loop pdf.png (63.87 KiB) Viewed 16796 times
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

Re: open list file

Post by farshadmo368 » 01 Jun 2018 15:02

i love you Desmanto
Let me test

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

Re: open list file

Post by farshadmo368 » 01 Jun 2018 15:39

You very good
You are a computer god.
You're a peach.
Works.
Thankful

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: open list file

Post by digitalstone » 01 Jun 2018 15:45

Yeah Desmanto... you're peachy haha :lol:
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

Re: open list file

Post by farshadmo368 » 08 Jun 2018 21:37

Hi desmanto how are you?
I want to clear that file after a few seconds after opening any of the files, how?
Attachments
Screenshot_2018-06-09-01-58-00-125_ch.gridvision.ppam.androidautomagic.png
Screenshot_2018-06-09-01-58-00-125_ch.gridvision.ppam.androidautomagic.png (114.15 KiB) Viewed 16628 times

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: open list file

Post by Desmanto » 09 Jun 2018 10:28

Almost the same, but you have to add some new variable to store the delete list.

But first, do you really need to delete it every time after each opening? Or can you just wait until the whole 1000 loop finish and finally delete the 1000 files at the same time? I prefer the later if possible. Since you don't need to loop delete for 1000 times (takes much longer time), only need to delete 1 time, but 1000 files at once.

If you need to loop delete after each opening, just add a newList (delete) to accomodate the deletion. We don't use the same list (pdf), as delete Files action require a common path version, not the uri path version.

Code: Select all

pdf = newList();
delete = newList();
for(i in files)
{
  if(endsWith(i, "pdf"))
  {
    addElement(pdf, "file:///" + replace(encodeURL(i), "%2F", "/"));
    addElement(delete, i);
  }
}
index = 0;
len = length(pdf);
use {delete[index]} in the Delete Files action.

=========================
But if you can wait until the whole operation finish, then you can move the action Delete Files to the end after the loop (after the loop expression) and use {delete,listformat,comma} in the Delete Files action. This will delete 1000 files at once after all pdf opening is finished.

Be careful when dealing with Delete Files action. I suggest you test this first using notification on screen (or condition debug dialog), to show the delete path, check whether it is correct already. Make sure you also have make a copy of the test file, in case something wrong, you still have the backup.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

farshadmo368
Posts: 31
Joined: 31 May 2018 09:18

Re: open list file

Post by farshadmo368 » 09 Jun 2018 13:10

Thank you

Locked