You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何基于文件名时间模式生成指定时段的监控视频文件列表

Hey there, let's figure out how to get that filtered list of your camera videos quickly. Based on your file structure and the time range you care about (8:00 AM to 5:00 PM), brace expansion is exactly the right tool here—super efficient for matching patterns like this.

First, let's recap your setup to make sure we're on the same page:

Your video path format: [Date Folder]/AM|PM/sricam-[date]-[time]-sequence#.mp4
Goal: Only include videos recorded between 8:00 AM and 17:00 (so AM hours 8-12, PM hours 1-5, since PM 1 = 13:00, PM 5 = 17:00)

Using Brace Expansion to List Valid Videos

Here's a bash command that uses brace expansion to target exactly those time slots. Run this in the parent directory that holds all your date folders:

ls */{AM/sricam-*-0{8,9,10,11,12}-*.mp4,PM/sricam-*-0{1,2,3,4,5}-*.mp4}

Breakdown of the command:

  • */ matches every top-level date folder (so you don't have to specify each date manually)
  • The outer {AM/..., PM/...} lets us target both AM and PM subfolders in one go
    • AM/sricam-*-0{8,9,10,11,12}-*.mp4 grabs all AM videos from 8:00 to 12:00—0{8,9,10,11,12} expands to 08, 09, 10, 11, 12 to match the hour part of the filename
    • PM/sricam-*-0{1,2,3,4,5}-*.mp4 captures PM videos from 1:00 to 5:00 (which maps to 13:00-17:00 in 24-hour time)

If you want to save this list to a text file instead of just printing it to the terminal, add a redirect:

ls */{AM/sricam-*-0{8,9,10,11,12}-*.mp4,PM/sricam-*-0{1,2,3,4,5}-*.mp4} > valid_camera_videos.txt

Quick Notes:

  • If your filenames include minutes (like 0830 for 8:30 AM), adjust the pattern to 08* instead of 08 to capture all times starting with that hour. For example: AM/sricam-*-08*-*.mp4
  • This relies on shell brace expansion, which works in bash, zsh, and most modern shells—if you're using an older shell, this trick won't apply.

内容的提问来源于stack exchange,提问作者Max

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:32:58