An open API service indexing awesome lists of open source software.

https://github.com/tdanks2000/vtools

A command-line tool to delete videos shorter than a specified duration from a folder.
https://github.com/tdanks2000/vtools

batch-processing cleaner cli cross-platform ffmpeg ffprobe tools video video-tools

Last synced: 16 days ago
JSON representation

A command-line tool to delete videos shorter than a specified duration from a folder.

Awesome Lists containing this project

README

          

# VTools - Video Cleanup CLI

A command-line tool to delete videos shorter than a specified duration from a folder.

## Features

- Delete videos that are shorter than a specified minimum duration
- Support for various video formats (mp4, avi, mkv, mov, wmv, flv, webm, m4v, 3gp, mpg, mpeg)
- Flexible duration input using natural language (e.g., "30 minutes", "1 hour", "90s")
- Dry-run mode to preview what would be deleted
- Progress tracking and detailed output

## Prerequisites

✅ **No external dependencies required!** FFmpeg is now bundled with the package using `ffmpeg-static`.

## Installation

1. Clone or download this repository
2. Install dependencies:
```bash
bun install
```

## Usage

### Basic Command

```bash
bun run start clean [options]
```

### Examples

```bash
# Delete videos shorter than 30 minutes
bun run start clean ./videos "30 minutes"

# Delete videos shorter than 1 hour
bun run start clean C:\Videos "1 hour"

# Delete videos shorter than 90 seconds
bun run start clean ./downloads "90s"

# Preview what would be deleted (dry run)
bun run start clean ./videos "5 minutes" --dry-run
```

### Duration Formats

The tool accepts various duration formats thanks to the `ms` library:

- `"30 minutes"` or `"30m"`
- `"1 hour"` or `"1h"`
- `"90 seconds"` or `"90s"`
- `"2.5 hours"`
- `"45min"`

### Options

- `--dry-run`: Preview what would be deleted without actually deleting files

### Global Installation (Optional)

To use the tool globally:

```bash
bun link
vtools clean [options]
```

## How It Works

1. Scans the specified folder for video files
2. Uses FFprobe to determine the duration of each video
3. Compares the duration against the specified minimum
4. Deletes videos that are shorter than the minimum duration
5. Provides detailed progress and summary information

## Safety Features

- **Dry-run mode**: Test the command safely before actual deletion
- **File validation**: Only processes recognized video file extensions
- **Error handling**: Skips files that can't be processed instead of crashing
- **Detailed logging**: Shows exactly what's happening with each file

## Supported Video Formats

- MP4 (.mp4)
- AVI (.avi)
- MKV (.mkv)
- MOV (.mov)
- WMV (.wmv)
- FLV (.flv)
- WebM (.webm)
- M4V (.m4v)
- 3GP (.3gp)
- MPG/MPEG (.mpg, .mpeg)

## Example Output

```
🎬 Video Cleanup Tool
Folder: C:\Videos
Found 5 video file(s) to check...
Minimum duration: 30 minutes

Checking (1/5): short_clip.mp4
Duration: 2 minutes
✅ Deleted (shorter than minimum)

Checking (2/5): movie.mkv
Duration: 1 hour 45 minutes
✅ Keeping (meets minimum duration)

--- Summary ---
Files checked: 5
Files deleted: 2
```

## Troubleshooting

### Permission errors

Ensure you have write permissions to the folder containing the videos.

### "Could not determine duration" warnings

This usually means the file is corrupted or not a valid video file. The tool will skip these files.

## Development

```bash
# Run in development mode with auto-reload
bun run dev

# Build for production
bun run build
```

## License

MIT License - feel free to use and modify as needed.