KeyRoutines
StepFreelist.getItem

Get the first, last or any item from a list on Windows

Get list item takes one item from a list by its position. Use it to grab the first search result, the last line of a file, or a random pick from a list.

How it works

  • Give it the list and the position: 1 for the first, 2 for the second, -1 for the last.
  • It returns the item and whether it was found.
  • A position past the end doesn't fail the step; found is just false.

Routines that use it

Newest download

Sort files by date with Sort list, Z to A, and get item 1 to open with Open file or folder.

Random wallpaper

Pick a random position with Random number and set that image with Set wallpaper.

Last line

Split a log with Split text, take item -1 and check it with Compare values.

Settings

SettingWhat it does
ListThe list.
PositionWhich item: 1 for the first, 2 for the second, -1 for the last.

Questions

How do I get the last item in a list?
Set the position to -1. Negative positions count from the end.
What if the list is shorter than the position?
The step succeeds with found set to false, so you can handle it with an If.

Pairs well with

Build this routine in KeyRoutines

Free from the Microsoft Store for Windows 11 and 10. Pro is a one-time upgrade.