Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6725899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:51:43+00:00 2026-05-26T09:51:43+00:00

I have the following which returns how many seconds a selected video file is.

  • 0

I have the following which returns how many seconds a selected video file is.

However I was after a way to just give it the movie folder and for it to then loop through all subdirectories and find all video file types.

Once it has these I would like to list the video length in “1 hour 53 seconds” type format as “7990 seconds” isn’t too helpful.

Thanks

set macPath to (choose file) as text
tell application "System Events"
    set ts to time scale of movie file macPath
    set dur to duration of movie file macPath
    set movieTime to dur / ts
end tell
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:51:44+00:00Added an answer on May 26, 2026 at 9:51 am

    You have several sub-questions involved in your question.

    1) How do I get all of the files in a folder, including the sub folders
    2) how do I filter that list to only include video files
    3) How do I loop through that list of video files and extract information from each and
    4) How do I convert seconds into a useable string of words

    Normally I would ask that you break it down into those individual questions because it’s a large task for someone to write the whole thing for you. However, in this case you’re lucky because I had done this before myself… so you can have my script. I put lots of comments in the code to help you learn how it works.

    -- I found these extensions for video files here http://www.fileinfo.net/filetypes/video
    -- we can check the file extensions of a file against this list to evaluate if it's a video file
    set video_ext_list to {"3g2", "3gp", "3gp2", "3gpp", "3mm", "60d", "aep", "ajp", "amv", "asf", "asx", "avb", "avi", "avs", "bik", "bix", "box", "byu", "cvc", "dce", "dif", "dir", "divx", "dv", "dvr-ms", "dxr", "eye", "fcp", "flc", "fli", "flv", "flx", "gl", "grasp", "gvi", "gvp", "ifo", "imovieproject", "ivf", "ivs", "izz", "izzy", "lsf", "lsx", "m1v", "m2v", "m4e", "m4u", "m4v", "mjp", "mkv", "moov", "mov", "movie", "mp4", "mpe", "mpeg", "mpg", "mpv2", "msh", "mswmm", "mvb", "mvc", "nvc", "ogm", "omf", "prproj", "prx", "qt", "qtch", "rm", "rmvb", "rp", "rts", "sbk", "scm", "smil", "smv", "spl", "srt", "ssm", "svi", "swf", "swi", "tivo", "ts", "vdo", "vf", "vfw", "vid", "viewlet", "viv", "vivo", "vob", "vro", "wm", "wmd", "wmv", "wmx", "wvx", "yuv"}
    
    -- get the folder to check
    set f to choose folder
    
    -- notice the use of "entire contents" to also go through subfolders of f
    -- use a "whose" filter to find only the video files
    tell application "Finder"
        set vidFiles to (files of entire contents of f whose name extension is in video_ext_list) as alias list
    end tell
    
    -- use a repeat loop to loop over a list of something
    set vidList to {} -- this is where we store the information as we loop over the files
    repeat with aFile in vidFiles
        -- get some information from aFile
        tell application "System Events"
            set vidFile to movie file (aFile as text)
            set ts to time scale of vidFile
            set dur to duration of vidFile
        end tell
    
        -- add the information to the "storage" list we made earlier
        set end of vidList to {POSIX path of aFile, secs_to_hms(dur / ts)}
    end repeat
    
    return vidList
    
    (*=================== SUBROUTINES ===================*)
    -- convert seconds into a string of words
    -- the use of "mod" and "div" here makes it easy
    -- we also make sure that each value is at least 2 places long to make it look nicer
    on secs_to_hms(the_secs)
        set timeString to ""
        set hr to the_secs div hours
        if hr is not 0 then set timeString to timeString & (text -2 thru -1 of ("0" & (hr as text))) & " hours "
    
        set min to the_secs mod hours div minutes
        if min is not 0 then set timeString to timeString & (text -2 thru -1 of ("0" & (min as text))) & " minutes "
    
        set sec to the_secs mod minutes div 1
        if sec is not 0 then
            set fraction to text 2 thru 3 of ((100 + the_secs mod 1 * 100) as text)
            set timeString to timeString & (sec as text) & "." & fraction & " seconds"
        end if
    
        if timeString ends with space then set timeString to text 1 thru -2 of timeString
        return timeString
    end secs_to_hms
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query which returns a list of questions and the possible
I have the following statement SELECT id, descr from mytable which returns 1, 'Test1'
NHibernate is driving me 'Nuts'!!! I have the following mapping. Which returns this error
I have the following code which works fine. However, I only want to return
i have the following code snippet. in which i just want to return PartyName
I have the following find function: $this->MyModel->find('all', array('conditions' => array('id' => $id))); which returns
I have the following code which returns results back from a database where columnName
I have this following code which will return all the current semesters. How do
I have some JS code which generates the following object, return { type: some
I have following code which works for radio buttons but need to be changed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.