tips
98 tips Files and media
One command, setting or habit at a time about Files and media: what it does, the line to copy and a caveat or two.
Files and media 98
-
Quickly detect a changed or damaged file with a very fast, non-cryptographic hash.
xxhsum -H64 backup.tar > backup.xxh -
Restore the date, camera and GPS tags of a photo from the original file.
exiftool -TagsFromFile original.jpg -all:all edited.jpg -
Leaves .git and other version control folders out of a tar archive.
tar --exclude-vcs -czf project.tar.gz project/ -
Remembers which videos were downloaded so a re-run only fetches new ones.
yt-dlp --download-archive archive.txt "https://www.youtube.com/playlist?list=PLAYLIST_ID" -
Unpack the files of a zip flat into one directory, ignoring its folder structure
unzip -j archive.zip -d out/ -
Writes selected metadata tags of many files into one CSV file you can open in a spreadsheet.
exiftool -csv -FileName -Model -LensModel -ISO -r photos/ > photos.csv -
Renames every photo in a folder after the date and time stored in its EXIF data.
exiftool '-FileName<CreateDate' -d %Y%m%d_%H%M%S%%-c.%%e photos/ -
Prints the available HandBrake presets so you can encode from the terminal with one of them.
HandBrakeCLI -z -
Combines many images into one grid image with a single ImageMagick command.
montage *.jpg -tile 4x -geometry 300x300+4+4 sheet.jpg -
Edits the language or default flag of an MKV track in place, in a fraction of a second.
mkvpropedit movie.mkv --edit track:a1 --set language=eng -
Repeats an input a set number of times, which is handy for loops and background videos.
ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 -
Fades the picture and the sound in at the start and out at the end of a clip.
ffmpeg -i in.mp4 \ -
Copies the content of a web URL directly to a remote without saving a temporary file.
rclone copyurl https://example.com/files/big.iso remote:isos -a -
Prints the total size and number of objects at a remote path, optionally as JSON.
rclone size remote:photos -
Debug logging is not in the Jellyfin web interface. You switch it on in a config file.
"Serilog": { -
One command line option sets hostwebclient to false, so the server hosts no web client.
jellyfin --nowebclient -
Switch the SQLite locking mode to Optimistic when scans fail with Database Locked in the log.
-
Prints your remote settings with secrets hidden so you can ask for help.
rclone config redacted -
Explores a remote's folder sizes in a text interface before you clean up.
rclone ncdu remote:backup -
Throttles a long upload during working hours and opens it up at night.
rclone copy /data remote:data --bwlimit "08:00,1M 18:00,5M 23:00,off" -P -
Lists remote files with exactly the columns you ask for.
rclone lsf -R --files-only --format tsp remote:photos -
Reports total, used, free and trashed space for a cloud account.
rclone about remote: -
Compares local files with their encrypted copies using checksums.
rclone cryptcheck /mnt/user/photos secret:photos --one-way -
Keeps your skip rules in a readable file you can test first.
- *.tmp -
Opens a cloud remote as a folder without any risk of changing it.
rclone mount remote:backup ~/restore --read-only -
Shuffle lines, draw a few at random, or pick a random number.
shuf -n 3 films.txt -
Turn a PDF into plain text you can search or paste.
pdftotext -layout invoice.pdf invoice.txt -
Move a link from a terminal session to your phone by scanning it.
qrencode -t ANSIUTF8 'https://example.com/a/long/path?id=12345' -
Puts an SRT file into an MP4 as a subtitle track instead of burning it into the picture.
ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4 -
Converts surround audio to two channels so it plays well on laptops and headphones.
ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv -
Saves the sound of a video file as a separate audio file without re-encoding it.
ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a -
Makes ffmpeg skip an output that is already there instead of asking or replacing it.
ffmpeg -n -i "$f" -c copy "${f%.mkv}.mp4" -
Rotates the picture of a video by 90 degrees, clockwise or counterclockwise.
ffmpeg -i sideways.mp4 -vf transpose=1 -c:a copy upright.mp4 -
Makes a video from a still image and a sound file, for sites that only accept video.
ffmpeg -loop 1 -i cover.jpg -i episode.mp3 -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a aac -shortest episode.mp4 -
Deinterlaces old TV or camcorder footage so moving parts don't show striped edges.
ffmpeg -i tape.avi -vf yadif -c:v libx264 -crf 20 -c:a aac tape.mp4 -
Builds a GIF from a video with a color palette made for that clip.
ffmpeg -i clip.mp4 -vf "fps=10,scale=480:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse" clip.gif -
Sets the codec tag Apple players expect, so an HEVC file plays in QuickTime and Safari.
ffmpeg -i input.mkv -c:v libx265 -crf 26 -tag:v hvc1 -c:a aac output.mp4 -
Turns a video into a series of still images at a fixed interval, for previews or contact sheets.
ffmpeg -i recording.mp4 -vf fps=1/60 thumbs/thumb-%03d.jpg -
Reports the average and peak volume of a file so you know how much to adjust it.
ffmpeg -i episode.mp3 -af volumedetect -f null - 2>&1 | grep -E 'mean_volume|max_volume' -
Changes the playback speed of the picture, for a timelapse or a slow motion clip.
ffmpeg -i build.mp4 -vf "setpts=0.25*PTS" -an build-4x.mp4 -
Makes ffmpeg copy all audio and subtitle tracks instead of picking one per type.
ffmpeg -i film.mkv -map 0 -c copy film-copy.mkv -
Makes a silent copy of a video, with the video stream copied as it is.
ffmpeg -i clip.mp4 -c:v copy -an clip-silent.mp4 -
Decodes a whole file without saving anything and prints only the errors it finds.
ffmpeg -v error -i movie.mkv -f null - -
Sets the language tag on audio or subtitle tracks so players show the right name.
ffmpeg -i film.mkv -map 0 -c copy -metadata:s:a:0 language=eng -metadata:s:a:1 language=nld film-tagged.mkv -
Cuts a part out of a video between two times, with a fast or an exact method.
ffmpeg -ss 00:01:00 -to 00:01:30 -i match.mp4 -c:v libx264 -crf 20 -c:a aac goal.mp4 -
Makes Jellyfin list a Season 00 special next to the regular episode it aired around.
/shows/Series Name (2018)/Season 00/Behind the scenes.mkv -
Gives the season folder and file name patterns Jellyfin reads reliably, and the characters to avoid.
/shows/Series Name (2018) [imdbid-tt1234567]/Season 05/Series Name S05E01.mkv -
Explains that a file with two episodes appears as one entry and that splitting is recommended.
/shows/Series Name (2018)/Season 01/Series Name S01E01.mkv -
Sets the Jellyfin cache directory with a command line option or an environment variable.
jellyfin --cachedir /srv/jellyfin-cache -
Puts lyrics next to a track so Jellyfin can show them, synced when the file has time stamps.
/music/Artist/Album/Song 1.flac -
Shows which NFO file names Jellyfin reads and why they override online providers.
/movies/Movie (2021)/Movie (2021).mkv -
Compares the files in a source against a remote destination by size and hash, without copying anything.
rclone check /mnt/user/photos remote:photos --one-way -
Explains the Jellyfin Local Networks field and the CIDR format it expects.
192.168.1.0/24, 10.0.0.0/8 -
Warns that a Jellyfin base URL needs a restart and breaks some connected apps.
Base URL: /jellyfin -
Remuxes an audio-only file to .mka without re-encoding when Jellyfin will not play it.
ffmpeg -i input.mkv -c:a copy output.mka -
Starts the cut a fixed time before the end of the file, whatever its length.
ffmpeg -sseof -30 -i recording.mkv -c copy last30.mkv -
Joins several video files into one without re-encoding, using a text file as the list.
file 'part1.mp4' -
Builds a video from a folder of numbered images, with the frame rate you pick.
ffmpeg -framerate 10 -i 'img-%03d.jpeg' out.mkv -
Prints only the length of a media file in seconds, with no labels around it.
ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 input.mp4 -
Delays one stream against another, which fixes audio that is a fixed moment out of sync.
ffmpeg -i movie.mp4 -itsoffset 0.5 -i movie.mp4 -map 0:v -map 1:a -c copy fixed.mp4 -
Measures the black borders in a video so you know the exact crop to use.
ffmpeg -i file.mp4 -vf cropdetect,metadata=mode=print -f null - -
Makes an audio file play faster or slower and writes it as a new file.
ffmpeg -i talk.mp3 -af atempo=1.25 talk-fast.mp3 -
Lists where an audio file goes quiet, without changing the file.
ffmpeg -i recording.mp3 -af silencedetect=n=-50dB:d=5 -f null - -
Keeps the files a sync would overwrite or delete in a separate folder on the same remote.
rclone sync --interactive /mnt/user/appdata/<app> remote:current --backup-dir remote:old -
Prints the hardware acceleration methods your ffmpeg build was compiled with.
ffmpeg -hide_banner -hwaccels -
Makes rclone stop with an error when a sync would delete more files than the limit you set.
rclone sync /mnt/user/appdata/<app> remote:backup --max-delete 50 -
Cuts one video into numbered files of a fixed length in a single command.
ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4 -
Explains why disc number and total discs tags decide how Jellyfin builds multi-disc albums.
/music/Artist/Album/Disc 1/01 Song.flac -
Sets a main Jellyfin configuration option through an environment variable with double underscores.
JELLYFIN_HttpListenerHost__DefaultRedirectPath=/web/ -
Combines several files of one movie into a single Jellyfin item with a version picker.
Movie (2021) [imdbid-tt12801262]/ -
Merges files named with a cd1, cd2 or part-1 suffix into one Jellyfin item.
Movie Name (2010)/ -
Lists videos in certain subfolders as extras of a movie or series in Jellyfin.
behind the scenes/Finding the right score.mp4 -
Overrides the artwork of a Jellyfin item by naming image files next to the media.
Movie (2035)/ -
Hides a folder, or single files by pattern, from Jellyfin library scans.
touch "/mnt/user/media/tv/Series (2010)/OST/.ignore" -
Sets language, default, forced and hearing-impaired flags of an external subtitle through its file name.
Film (1986)/ -
Plays a theme song or video in the background when you open a show in Jellyfin.
theme.mp3 -
Copies a video to a new file without its global metadata or chapters.
ffmpeg -i in.mp4 -map_metadata -1 -map_chapters -1 -c copy out.mp4 -
Lists and removes metadata from documents, images and other files, writing a cleaned copy.
mat2 --show report.pdf -
Makes an rclone copy add new files but never overwrite or delete the ones already at the destination.
rclone copy --immutable /mnt/user/appdata/<app>/exports remote:archive -
Rewrites an MP4 so the index is at the start and playback begins before the download ends.
ffmpeg -i in.mp4 -c copy -movflags +faststart out.mp4 -
Seeks to a timestamp before reading the file, then saves a single frame as an image.
ffmpeg -ss 00:01:30 -i input.mp4 -frames:v 1 thumbnail.png -
Converts audio, for example WAV to AAC, with a converter that already comes with macOS.
afconvert -f m4af -d aac -b 256000 recording.wav recording.m4a -
Leaves Mac and git clutter out of a zip archive you make in the terminal.
zip -r site.zip site -x '*.DS_Store' '*/.git/*' -
Measures ratio and speed of each zstd level on your data, so you can pick one.
zstd -b1 -e19 app-backup.tar -
Leaves cache folders out of a tar backup by marking them with one small file.
printf 'Signature: 8a477f597d28d172789f06886806bc55' > /mnt/user/appdata/app/cache/CACHEDIR.TAG -
Makes tar backups that only contain the files that changed since the previous run.
tar -czf /backup/docs-0.tar.gz -g /backup/docs.snar /home/user/docs -
Unpacks an archive straight into an existing folder without the extra version folder.
tar -xzf app-2.4.1.tar.gz -C /mnt/user/appdata/app --strip-components=1 -
Marks a different audio or subtitle track as the default in a video file, without re-encoding.
ffmpeg -i in.mkv -map 0 -c copy -disposition:a:0 0 -disposition:a:1 default out.mkv -
Normalizes the loudness of audio or a video's soundtrack to a fixed target with ffmpeg.
ffmpeg -i in.mp4 -c:v copy -af loudnorm=I=-23:TP=-2:LRA=7 -ar 48000 -c:a aac -b:a 192k out.mp4 -
Draws an .srt or embedded subtitle track permanently onto the picture of a video.
ffmpeg -i clip.mp4 -vf subtitles=clip.nl.srt -c:a copy clip-subbed.mp4 -
Preallocates disk space for a file of the size you ask, without writing all the data like dd would.
fallocate -l 1G test.img -
Encodes video at constant quality with H.264 or H.265, so you pick a CRF number instead of a bitrate.
ffmpeg -i in.mp4 -c:v libx264 -crf 23 -preset medium -c:a copy out.mp4 -
Scales a video to a fixed width and works out an even height so the picture is not stretched.
ffmpeg -i in.mp4 -vf scale=1280:-2 -c:a copy out.mp4 -
Prints the container format and every stream of a media file, so you see codecs, resolution and duration.
ffprobe -v error -show_format -show_streams video.mkv -
Moves a video into another file format in seconds, without re-encoding or quality loss.
ffmpeg -i movie.mkv -c copy movie.mp4 -
Removes GPS position and all other metadata from a photo before you share it.
exiftool -all= photo.jpg -
Shows what is inside a tar archive without extracting it, and pulls out a single file.
tar -tf backup.tar.gz | head -
Shows which files rclone sync would copy or delete, before anything changes.
rclone sync /data remote:backup --dry-run -v
Nothing in this filter yet.