| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| create_pdf_from_jpgs_imagemagick.sh | 2025-11-30 | 24.3 kB | |
| map-route.sh | 2025-11-11 | 6.2 kB | |
| stream-info.sh | 2025-11-07 | 4.2 kB | |
| Read_KEY.sh | 2025-11-06 | 4.3 kB | |
| cursor_movments.sh | 2025-09-29 | 58.3 kB | |
| configure_terminal.sh | 2025-09-29 | 58.3 kB | |
| ifs.sh | 2025-09-29 | 52.5 kB | |
| README.md | 2025-08-14 | 3.9 kB | |
| sort-media-copy.sh | 2025-08-13 | 9.3 kB | |
| Totals: 9 Items | 221.2 kB | 1 | |
A script for automatically finding, categorizing, and copying multimedia files based on their video resolution. This is particularly useful for organizing a large collection of video files into logically named subdirectories.
π Features
Automatic Sorting: Finds video files in the current directory and sorts them into subdirectories named after their resolution (e.g., 1920x1080).
Date Filtering: Use the -t or --time option to copy only files modified after a specific date. This is perfect for managing new additions without affecting your existing library.
Custom Destination: Use the -d or --destination option to specify a central directory where all the sorted files will be copied.
File Renaming: Add the -r or --rename option to automatically append the video resolution to the copied file's name (e.g., my_video.mp4 becomes my_video_1920x1080.mp4).
Dependency Checks: Automatically verifies that all necessary programs (find, cp, ffmpeg, ffprobe) are installed before running.
βοΈ Requirements
This script relies on the following command-line tools to function:
find
cp
ffmpeg
ffprobe (part of the ffmpeg package)
On most Linux distributions, you can install ffmpeg and its related tools using your package manager. For example:
Debian/Ubuntu: sudo apt-get install ffmpeg
Arch Linux: sudo pacman -S ffmpeg
Fedora: sudo dnf install ffmpeg
For environments like Termux, use pkg install ffmpeg.
π Getting Started
Save the script: Save the provided code into a file named sort-media-copy.sh.
Make it executable: Grant the script execution permissions.
Bash
chmod +x sort-media-copy.sh
Run the script: Execute the script from your terminal with the desired options. Bash
./sort-media-copy.sh
π Usage
Bash
Usage: ./sort-media-copy.sh [OPTIONS] Script for finding and copying multimedia files from the current directory.
Options
Option Description Example -h, --help Displays the help message and exits. ./sort-media-copy.sh --help -i, --info Displays detailed information and instructions about the script. ./sort-media-copy.sh -i -t "YYYY-MM-DD", --time "YYYY-MM-DD" Copies files modified after a specific date. ./sort-media-copy.sh -t "2024-08-01" -d "/path/to/directory", --destination "/path/to/directory" Copies all files to a specified central directory. ./sort-media-copy.sh -d "/home/user/my_videos" -r, --rename Renames the copied files by appending their resolution to the filename. ./sort-media-copy.sh -r
π‘ Examples
Copy and sort all video files from the current directory:
Bash
This command will create resolution-based subdirectories within the same folders as the original files.
Copy and sort new files to a specific directory: Bash
./sort-media-copy.sh -t "2024-08-10" -d "/media/my_archives"
This command will find all video files modified after August 10, 2024, and copy them into subdirectories (e.g., /media/my_archives/1920x1080/) inside the /media/my_archives folder.
Copy and rename files to a central location: Bash
./sort-media-copy.sh -d "/my_videos" -r
This will copy all video files to /my_videos and rename them to include their resolution, for example, clip.mp4 will be copied as clip_1280x720.mp4.
π Notes
If a file's resolution cannot be determined by ffprobe, it will be copied to a directory named unknown.
The script currently supports .mp4, .webm, .mkv, .avi, and .mov file extensions. You can modify the find command in the script to include more file types.
The CACHE_DIRS variable in the script is set to "." by default, meaning it will only search the current directory. You can modify this variable to include additional directories if needed.
βοΈ Author
Leszek Ostachowski
π License
This script is released under the GPL V2 license.