List all files except the two most recent in a folder

(imported topic written by MattPeterson)

I’m trying to create a relevance statment to list files in a folder, excluding the two most recent files. I can write a stamement to exclude the most recent, but I’m having a hard time excluding the two most recent. Ideally I would want a statement that would allow me to change the number of files I want to exclude.

Here is what I have to exclude the most recently modified file:

pathnames of files whose (modification time of it != maximum of modification times of files of parent folder of it) of folder “C:\test”

(imported comment written by BrianPGreen)

This is a non-answer, but I think you can solve it by re-applying that same pattern, and using tuples to pass on both an individual file and the current set of files. If you’re still working on this, reply to this post and we can try to figure something out.

(imported comment written by MattPeterson)

I was hoping for something that would be a little more flexible that would allow me to change the number of files easily (say from 2 to 10). I did try to get something like your suggesting to work, but didn’t have any luck. I always seem to have problems using maximum of in a set. Any help would be appreciated.

(imported comment written by jgstew)

UPDATED WITH FIXES

I also struggle with issues like this.

I was able to solve this using triple recursion (very inefficient with large sets of files)

q: tuple string item ((number of unique values of modification times of files of folder “c:\temp”) - 2) of concatenation ", " of following texts of firsts ", " of (it as string) of unique values of modification times of files of folder “c:\temp”

q: ((number of unique values of modification times of files of folder “c:\temp”) - 2)

q: files whose(modification time of it <= ((it as time) of tuple string item ((number of unique values of modification times of files of folder “c:\temp”) - 2) of concatenation ", " of following texts of firsts ", " of (it as string) of unique values of modification times of files of folder “c:\temp”)) of folder “c:\temp”

http://bigfix.me/relevance/details/2999086

(imported comment written by MattPeterson)

This almost worked…

But, because the modification time has a comma (Wed, 28 May 2014 13:45:15 -0500), the tuple is detecting time as two items. Any suggestions on how I could get around that?

q:

tuple string

item

((
number of

unique values

of

modification times

of

files

of

folder

“c:\test”
)

2
)

of

concatenation

", "

of

(
it

as

string)

of

unique values

of

modification times

of

files

of

folder

“c:\test”

A:
Tue

T:
6.064 ms

I:
singular string

q:
((
number of

unique values

of

modification times

of

files

of

folder

“c:\test”
)

2
)

A:
18

T:
3.039 ms

I:
singular integer

q:
files

whose
(modification time

of

it

<=

((
it

as

time)

of

tuple string

item

((
number of

unique values

of

modification times

of

files

of

folder

“c:\test”
)

2
)

of

concatenation

", "

of

(
it

as

string)

of

unique values

of

modification times

of

files

of

folder

“c:\test”
))

of

folder

“c:\test”

T:
118.171 ms

I:
plural file

(imported comment written by jgstew)

You’re right about the “,” in the time string… which makes me wonder why it seemed to work for me.

The fix is to just remove the Day short name and comma from the time string using ( following texts of firsts ", " of … )

q: following texts of firsts ", " of (it as string) of now

A: 29 Jul 2014 09:37:58 -0400

q: (it as time) of following texts of firsts ", " of (it as string) of now

A: Tue, 29 Jul 2014 09:38:16 -0400

See the fixed relevance in my original post.