Sum the length for selected video files at the state line. Is it possible?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Sergio Leone
Junior Member
Junior Member
Posts: 6
Joined: 2024-02-29, 12:54 UTC

Sum the length for selected video files at the state line. Is it possible?

Post by *Sergio Leone »

Hello.
Is it possible to configure TC to sum the length for selected video files and display it at the "state line" (near file size) ?
Here:
Image: https://i.postimg.cc/7L6RBD75/TC-issue.jpg
User avatar
Dalai
Power Member
Power Member
Posts: 9393
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *Dalai »

No, it's not and this has been discussed before. Use a plugin like MediaTime in conjunction with a custom columns view to get the total runtime of files within a directory. To get only the runtime of some of these files you could copy or hardlink them into a separate directory.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Sergio Leone
Junior Member
Junior Member
Posts: 6
Joined: 2024-02-29, 12:54 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *Sergio Leone »

ok... thank you!
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *tuska »

It is possible to determine the total time of media files (e.g. 3gp|asf|avi|mkv|mov|mp3|mp4|mpg|wma|wmv|vob)
by clicking a button - in a separate window(!) - not in the footer.

The following is required for this:
  1. .vbs file from user Fla$her
    1. Save the file e.g. under the following name: CalculatingTheTotalDurationOfSelectedMediaFiles.vbs
    2. Then drag the .vbs file into the button bar
    3. Add the following to the "Parameters" field:

      Code: Select all

      %WL 3gp|asf|avi|mkv|mov|mp3|mp4|mpg|wma|wmv|vob
    4. Option: Overwrite the entry in the "Icon file" field as follows:
      shell32.dll ... and select e.g. no. 118 as icon ...
    5. Add the following to the Tooltip field:

      Code: Select all

      CalculatingTheTotalDurationOfSelectedMediaFiles.vbs - Fla$her|Parameter: %WL 3gp||asf||avi||mkv<||mov||mp3||mp4||mpg||wma||wmv||vob|/c = copy the result to the clipboard|https://www.ghisler.ch/board/viewtopic.php?p=446565#p446565
  2. As already mentioned by user Dalai, install the Total Commander plugin MediaTime
    by double-clicking *in Total Commander(!)* on the file "wdx_MediaTime_1.1.rar".
    1. Position the cursor on a video file and hold down the Ctrl key
    2. Right-click on any column header and release the Ctrl key
    3. Select the menu item "Configure this custom columns view..."
    4. Click on the "Add column" button
    5. Enter the following:
      Name: Duration (1 level)
      Width: 65
      Field content: [=mediatime.Duration (1 level)]
    6. Click on the "Apply" button and then on "OK"
    7. The "Duration (1 level)" column shows the "Duration" of media files.
  3. Mark all media files e.g. with the command: cm_ExchangeSelBoth or only individual files
  4. Click on the button with the command: Path\to\CalculatingTheTotalDurationOfSelectedMediaFiles.vbs
  5. The total duration is displayed --> Important note: Always make sure that e.g. only video files are selected,
    because if there are .mp3 files among them, these would be included in the total runtime,
    due to the parameter setting: 3gp|asf|avi|mkv|mov|mp3|mp4|mpg|wma|wmv|vob
  6. Option: The total duration which is displayed in the separate window with the title "Total duration of selected media files"
    can be transferred to the clipboard using the "Textify" tool.
Sergio Leone
Junior Member
Junior Member
Posts: 6
Joined: 2024-02-29, 12:54 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *Sergio Leone »

tuska, thank you!
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *tuska »

2Sergio Leone

I would also like to add that the use of a "Custom columns view" is OPTIONAL (see point 2. above).
It would be sufficient to call the vb script via button to determine the total playing time.

In my opinion, however, the creation of a "Custom columns view" is highly recommended.

If you want to restore your previous view afterwards, I recommend using the button below.
The explanations of the individual commands can be found in the command browser
[button with command: cm_CommandBrowser] or in the "HISTORY.TXT" file.
BUTTON - View mode <default>
Configuration > Options... > View mode > <Default>
- Columns view: Full
- Sort order: Name

Code: Select all

TOTALCMD#BAR#DATA
cm_SrcViewMode0,cm_SrcAllFiles,cm_50Percent,cm_RereadSource,cm_rereadsource 1,cm_rereadsource 2,cm_rereadsource 3

wcmicons.dll,86
cm_SrcViewMode0,cm_SrcAllFiles,cm_50Percent,cm_RereadSource,cm_rereadsource 1,2,3|View mode <Default>: cm_SrcViewMode0|Active panel!|-|cm_RereadSource Ctrl+R|-|cm_rereadsource 1 )|cm_rereadsource 2 )|cm_rereadsource 3 ) --> see: HISTORY.TXT!


-1
Create a Button in the Buttonbar (copy/paste CODE)
  1. Click on "SELECT ALL" (to the right of CODE:), then press CTRL+C (copy to clipboard).
  2. Right-click on any place in the button bar, then click on "Paste".
     ⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
  3. Option1: Point to the new button (slightly longer): 'Tooltip' is shown (-> description to the button).
                  A maximum of 259 characters is allowed for the tooltip. | = create line break, || = create | as separator character.
  4. Option2: Button bar - "Tooltip" field: A single space deactivates the display of the tooltip.
                  If the "Tooltip" field is empty, the content of the "Command" field is displayed.
  5. Option3: See FAQs and explanation: Button-code (TOTALCMD#BAR#DATA)  <-- <Ctrl+click on the link...>


Windows 11 Pro (x64) Version 23H2 (OS Build 22631.3235) | TC 11.03 x64/x86
Overview: View Mode | Auto Switch Mode | Custom columns view
Sergio Leone
Junior Member
Junior Member
Posts: 6
Joined: 2024-02-29, 12:54 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *Sergio Leone »

2tuska, thanks.
I've done accordingly to your advices both variants - works great. More over, I've assigned Ctrl+i hotkey on VBS script calling, now it's much more convenient.
Previously for video length calculation i'd been using Alt+Enter --> Details - and it takes more time.
Found one issue with script: if do Ctrl+B (show all files from directories), select some videos and than calling a script it doesn't work. Got an error.
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *tuska »

Sergio Leone wrote: 2024-03-01, 06:35 UTC 2tuska, thanks.
I've done accordingly to your advices both variants - works great.
More over, I've assigned Ctrl+i hotkey on VBS script calling, now it's much more convenient.
I'm glad it worked out. :)
Sergio Leone wrote: 2024-03-01, 06:35 UTC Found one issue with script: if do Ctrl+B (show all files from directories),
select some videos and than calling a script it doesn't work. Got an error.
Mmh, I did not experience this behaviour with Branch View (With Subdirs) - Ctrl+B.
I would try it again with other directories.

[If the error still occurs, the script author may be able to help you].
Fla$her
Power Member
Power Member
Posts: 2318
Joined: 2020-01-18, 04:03 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *Fla$her »

tuska wrote: 2024-02-29, 14:34 UTC 5. The total duration is displayed --> Important note: Always make sure that e.g. only video files are selected,
because if there are .mp3 files among them, these would be included in the total runtime,
due to the parameter setting: 3gp|asf|avi|mkv|mov|mp3|mp4|mpg|wma|wmv|vob
Why, if it's easier to remove '|mp3' and '|wma' from the parameters?
This is just an example. Everyone can change the extension list as they want, as long as the codecs are in place.
There is also an option without coders, but with MediaInfoActiveX.dll. For those who need it, I can give a solution with this component.
tuska wrote: 2024-02-29, 14:34 UTC 6. Option: The total duration which is displayed in the separate window with the title "Total duration of selected media files"
can be transferred to the clipboard using the "Textify" tool.
Why, if there is already a /c key?

Sergio Leone wrote: 2024-03-01, 06:35 UTCGot an error.
Copy it in this window by Ctrl+C and paste it here.
Overquoting is evil! 👎
Sergio Leone
Junior Member
Junior Member
Posts: 6
Joined: 2024-02-29, 12:54 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *Sergio Leone »

2Fla$her screenshot
https://ibb.co/XJ8Jc5w

translation:
.....
string: 23
symbol: 4
Error: overflow '[string 769564]'
cod: 800A006
....
Fla$her
Power Member
Power Member
Posts: 2318
Joined: 2020-01-18, 04:03 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *Fla$her »

2Sergio Leone
The point is not Ctrl+B, but that the 3rd TimeSerial parameter cannot accept a number greater than 2¹⁵-1.
I've come across this before, but then I forgot.
Fixed:

Code: Select all

'—————————————————————————————— VBS —————————————————————————————
' Purpose: Calculating the total duration of selected media files
' Parameters: %WL <filter extensions via |> [/c]
'    /c — copy the result to the clipboard instead of displaying
'    Example: %WL 3gp|asf|avi|mkv|mov|mp3|mp4|mpg|wma|wmv|vob /c
'————————————————————————————————————————————————————————————————
Option Explicit: Dim A, oDesk, oFSO, oList, F, Dur
Const Title = " Total duration of selected media files"
Set A = WSH.Arguments: If A.Count = 0 Then WSH.Quit
Set oDesk = CreateObject("Shell.Application").NameSpace(0)
Set oFSO  = CreateObject("Scripting.FileSystemObject")
Set oList = oFSO.OpenTextFile(A(0),,,-1)
Do: F = oList.ReadLine
   If Right(F, 1) <> "\" Then _
   If InStr(1, "|" & A(1) & "|", "|" & oFSO.GetExtensionName(F) & "|", 1) Then _
   Dur = Dur + CDbl(oDesk.ParseName(F).ExtendedProperty("Duration"))
Loop Until oList.AtEndOfStream: oList.Close
Set oList = Nothing: Set oDesk = Nothing: Set oFSO = Nothing

If IsEmpty(Dur) Then
   MsgBox "There are no suitable media files!", 262192, Title
Else
   Dur = Duration(FormatNumber(CDbl(Dur/10000000), 0))
   If A.Named.Exists("c") Then
      With CreateObject("WScript.Shell")
         If .Run("%ComSpec% /q/c <nul set /p=""" & Dur & """|clip", 0, 1) Then _
         .Run "mshta ""javascript:close(clipboardData.setData('text','" & Dur & "'))""", 7
      End With
   Else MsgBox Space(14) & Dur, 262208, Title End If
End If

Function Duration(V)
   If V < 32768 Then
      Duration = Right("0" & TimeSerial(0, 0, V), 8)
   Else
      Dim D, H1, H, M1, M, S
      D = Int(V/86400) : H1 = V  - D * 86400
      H = Int(H1/3600) : M1 = H1 - H * 3600
      M = Int(M1/60)   : S  = M1 - M * 60
      If D = 0 Then D = "" Else _
      If D = 1 Then D = D & " day " Else D = D & " days "
      Duration = D & Right("0" & TimeSerial(H, M, S), 8)
   End If
End Function
Overquoting is evil! 👎
Sergio Leone
Junior Member
Junior Member
Posts: 6
Joined: 2024-02-29, 12:54 UTC

Re: Sum the length for selected video files at the state line. Is it possible?

Post by *Sergio Leone »

2Fla$her, works excelent. Thank you!
Post Reply