Question: Length of all videos in a folder

Discussion in 'Mac Basics and Help' started by JADWil, Sep 4, 2014.

  1. JADWil macrumors newbie

    Joined:
    Sep 4, 2014
    #1
    Hi guys,
    Sorry if this is not the place to post my question, but I didn't know where else to post it.

    Anyways, I have a folder that has around a 100 videos, each has a different length, and I would like to see how long are they all together. So is there anyway that I figure that out quickly?? I need to know how long they are, and I really don't want to look at each one individually


    Thanks
     
  2. inscrewtable macrumors 65816

    inscrewtable

    Joined:
    Oct 9, 2010
    Location:
    Australia
    #2
    If they are of a similar type then you may be able to get a pretty good estimate by the file size.
     
  3. Gregg2, Sep 5, 2014
    Last edited: Sep 7, 2014

    Gregg2 macrumors 603

    Joined:
    May 22, 2008
    Location:
    Milwaukee, WI
    #3
    Highlight the files, then go to Edit(or is it File?) > Get Info

    Now hold down the Option key. Get Info changes to Show Inspector. It will show you the total size.

    OOps! read that incorrectly. But size does matter, sometimes. :eek:
     
  4. Tomorrow macrumors 604

    Tomorrow

    Joined:
    Mar 2, 2008
    Location:
    Always a day away
    #4
    Use a program like VLC player and copy all the files to a playlist. It might give you a total run time for all the videos.
     
  5. matrix07 macrumors 68040

    matrix07

    Joined:
    Jun 24, 2010
    #5
    This is very smart.
     
  6. JADWil thread starter macrumors newbie

    Joined:
    Sep 4, 2014
    #6
    Thank you all, I actually used this:

    I just added the size of the longest 5 videos and divided their size by their length then multiplied it by the size of all the videos. that should be very close to their total length…. I have 227hrs of medical videos to watch :S it's going to be hectic!!
     
  7. Tomorrow macrumors 604

    Tomorrow

    Joined:
    Mar 2, 2008
    Location:
    Always a day away
    #7
    The only possible snag here is that if the videos all use different encryption or bitrates, your calculation will be off.
     
  8. JADWil thread starter macrumors newbie

    Joined:
    Sep 4, 2014
    #8
    hmm.. I honestly tried to play around with VLC like you said, it wouldn't give me a total time. I added the videos to a playlist, I also added them to VLC library, but nothing!! Is there a way to make VLC show me the total time??
     
  9. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #9
    Try this :

    Code:
    -- time the following operation:
    --set start_time to (time of (current date)) -- start timing
    
    set this_folder to (choose folder with prompt "Pick the folder containing the video files to process:") as string
    
    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"}
    
    
    tell application "Finder"
    	set these_files to ((files of folder this_folder whose name extension is in video_ext_list) as alias list)
    end tell
    
    set filesCount to count of these_files
    
    set total_duration_of_files_in_seconds to ""
    set files_with_no_duration to 0
    
    repeat with i from 1 to filesCount
    	set this_file to (item i of my these_files)
    	set this_info to info for this_file
    	if visible of this_info is true and alias of this_info is false then
    		-- insert actions here for: this_file
    		set this_file_duration_in_seconds to do shell script "mdls -name kMDItemDurationSeconds -raw -nullMarker 0 " & quoted form of POSIX path of this_file
    		if this_file_duration_in_seconds is not 0 then
    			set total_duration_of_files_in_seconds to total_duration_of_files_in_seconds + this_file_duration_in_seconds
    		else
    			set files_with_no_duration to files_with_no_duration + 1
    		end if
    	end if
    end repeat
    
    set total_duration_in_hms to do shell script " echo " & total_duration_of_files_in_seconds & " | awk '{printf \"%03d:%02d:%02d\",$0/3600,$0%3600/60,$0%60}'"
    
    (*
    set end_time to (time of (current date)) -- stop timing.
    set elapsed_time to end_time - start_time
    
    log "2. elapsed_time is is " & elapsed_time & " seconds."
    *)
    
    display dialog "Files processed : " & (count of these_files) & return & "Files without duration : " & files_with_no_duration & return & "Total duration of " & (count of these_files) - files_with_no_duration & " files in h:m:s : " & total_duration_in_hms with title "Length of all videos in a folder" buttons {"OK"} default button 1
    
    Note : Do not use the script on a folder with hundreds or more files. For your purpose of about 100 files it should be ok.
     

    Attached Files:

  10. matrix07 macrumors 68040

    matrix07

    Joined:
    Jun 24, 2010
    #10
    Oh, you want total time of ALL files. I thought you want total time of EACH file.
     

Share This Page