Move files except the last file

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
doc11
Posts: 14
Joined: 01 Oct 2018 11:39

Move files except the last file

Post by doc11 » 01 Oct 2018 20:10

Hello,

i have log files for every single day with the file format "yyyyMMdd.txt".
how can i move all files except the current day to another folder?

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

Re: Move files except the last file

Post by digitalstone » 01 Oct 2018 20:33

Are you familiar with loop iterations?
you could first store the amount of files within your folder, inside a list.

Then inside the loop:
look at each upfollowing file.
If its name equals today's date, then "don't copy" else "copy".
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

doc11
Posts: 14
Joined: 01 Oct 2018 11:39

Re: Move files except the last file

Post by doc11 » 01 Oct 2018 21:09

I found the following solution from Desmanto in the other thread:
viewtopic.php?f=5&t=6905

Only need the single line script

Code: Select all

removeElement(files, indexOfElement(files, "/storage/emulated/0/source/{getDate(),dateformat,yyyyMMdd.txt}"));

Then use {files,listformat,comma} at the Action Move Files.

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

Re: Move files except the last file

Post by digitalstone » 01 Oct 2018 21:44

Very nice, i wasn't aware of a dedicated function like that.

But for "educational purposes":
Under the hood, i bet it would perform a similar process like i described though.
It has to check every file up til the one you're looking for eventually somehow.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

Post Reply