SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio


SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Thread Tools Search this Thread Display Modes
Old 02-08-2007, 02:34 PM
Wirenut Wirenut is offline
Sage Advanced User
Join Date: Jun 2006
Posts: 183
Finding newest file

I am trying to point to a directory and retrieve the newest .jpg file there and pass that file to a picture widget and render it. If no file exists... passive listen. All triggered with a global, "custom3" listener.

I am only concerned with the newest file in a local directory. Seems easy.

My difficulty has been trying to sort and select the newest file... The filenames also have time and date so perhaps even sorting by filename should still work.

Any ideas or sample snippets will be welcomed.


Reply With Quote
Old 02-08-2007, 02:57 PM
Opus4's Avatar
Opus4 Opus4 is offline
Join Date: Sep 2003
Location: NJ
Posts: 19,619
You could sort the list of jpg file paths using GetPathLastModifiedTime as the SortTechnique. Is that what you are looking for? If not, what part are you missing?

Or, you may need to use the java call java_io_File_lastModified as the SortTechnique -- The reason I mentioned 2 different ways to get the file date is that you will use one or the other, depending on how you are getting the list of files. The SageTV API calls dealing with getting a list of files, and info about those files, works in the context of the server. Java File calls work in terms of the context of the client. (Placeshifter & Extender clients are Remote clients, which always operate in the server's context.)

- Andy
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
Old 02-08-2007, 05:36 PM
Wirenut Wirenut is offline
Sage Advanced User
Join Date: Jun 2006
Posts: 183
Well, I'm very new to this programming environment. But have programming experience with C and VB... No Java, but why not take a whack at Studio.

Essentially, I would have a directory full of picture files.... say c:\programs\data\images\.... so I believe I could read the list of files into an array;

then sort it by file name [which is incremental by date / time] with;

Sort(java.lang.Object Data,boolean Descending,java.lang.Object SortTechnique)

then select the first element of the array with;

GetElement(java.lang.Object Data, 1)

then pass that filename to the image widget for rendering?

I may be way-off the mark... I'm totally green here.

Much respect,


ps Client and Server are the same local machine.

Last edited by Wirenut; 02-08-2007 at 05:39 PM.
Reply With Quote
Old 02-08-2007, 06:48 PM
GKusnick's Avatar
GKusnick GKusnick is offline
Join Date: Dec 2005
Posts: 5,083
If you want to use Java file system calls, you'd best familiarize yourself with the Java API docs. is what you're looking for.

But realize that the code you write in Studio is not Java. It has Java-like (or for that matter C-like) expression syntax, but there are some important differences. You can call out to Java, but you need to use _ instead of . for qualifying Java package and class names as per p. 141 of the Studio manual.

Also note that the first element of an array is numbered 0, not 1.
-- Greg
Reply With Quote
Old 02-08-2007, 06:59 PM
Wirenut Wirenut is offline
Sage Advanced User
Join Date: Jun 2006
Posts: 183
Doh... yeah... 0 for the first index of the array.

Thanks GK.

I actually think I've got it working now.

This interface, albeit daunting, is very wide-open.

Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 03:22 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.