Verzeichnis Prüfung

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
frage
Posts: 43
Joined: 20 May 2017 12:15

Verzeichnis Prüfung

Post by frage » 22 Aug 2019 05:05

Hallo Forum,

ich suche nach einer Möglichkeit eine Verzeichnis zu prüfen.
Ich möchte das Automagic Premium kontrolloert ob in diesem
Verzeichnis Dateien enthalten sind.

Im zweiten Schritt soll geprüft werden welche dieser
Dateien am ältesten sind um eine Auswahl zu treffen.

Meine Script Kenntnisse sind noch nicht so gut,
das ich dieses Problem lösen kann.

Vielen Dank für Eure Hilfe.

Gruß
frage

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

Re: Verzeichnis Prüfung

Post by Desmanto » 22 Aug 2019 17:56

To monitor for a files/folder in folder path, use trigger File Observer. Usually the event you need is Writable file closed or Subfile created. But you have to try to see if it produce multiple execution, as different app can use different read/write method.

After triggered, you can use Init Variable File list on the same path. Tick Include File Attributes. This will get list of all files in the folder. I assume you want only the files, not including folder (if any). Below script will sort the files inside by their datetime (modified) and output it to sorted list with file name + datetime.

Code: Select all

//prepare temp list, to move the date to the first element so we can sort it
temp = newList();
for(i in files)
{
  if(i[1] == "file") //only check for file
    addElement(temp, newList(i[3], i[0], i[1], i[2]) );
}
sort(temp); //sort based on the datetime

//use regex to find the file name and combine it with the datetime
sorted = newList();
for(i in temp)
  addElement(sorted, findAll(i[1], '/.*/(.*)', true)[0][1] + " | {i[0],dateformat,HH:mm:ss dd-MMM-yyy}");
You can then use {sorted,listformat,comma} in the input dialog. Or if you just need the oldest file, you don't need the regex part. From the sort temp list, simply use temp[0][1], this contain the path to the oldest file in the folder.
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.

frage
Posts: 43
Joined: 20 May 2017 12:15

Re: Verzeichnis Prüfung

Post by frage » 05 Sep 2019 06:06

Hallo Desmanto,

danke für die Hilfestellung. Hatte nur vorher keine Zeit mich damit zu befassen.
Ich muss allerding gestehen, das ich in der Scriptsprache noch nicht so weit reichende
Kenntnisse habe. So ganz verstehe ich noch nicht wie ich das umsetzen muss.
Wie baue ich das in einen Flow ein. Meine bisherigen Versuche waren reines
probieren und ich hatte bisher keinen Erfolg.

Ich wäre dankbar für eine weitere Hilfe.

Mfg
frage

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

Re: Verzeichnis Prüfung

Post by Desmanto » 06 Sep 2019 06:15

What is the main purpose of the flow? What is the trigger? Is it file observer? Because if you use other than that, there is different method.

Using it for chrome download manager, or camera or other app can lead to different result. As chrome create temporary file, camera also can sometimes create temporary folder and other app may behave differently. But if you use manual trigger, to init a list of files in a folder, then you only need to use action init files only. And usually it is simpler if you don't need trigger file observer. But I still have to know the purpose first.
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.

Post Reply