Rename a video and its separate subtitles together by giving their copies a shared episode name. Keep any recognized language suffix on the subtitle file, then open the copied episode and select the intended caption track. A clean filename pairing helps the player associate the files. Timing, language, and episode identity still need a playback check.

This procedure serves a folder of MP4 videos and SRT sidecars from a completed export. It uses an explicit filename rule, prints every copy it proposes, and stops on a missing or ambiguous pair. The original files remain available under their old names. The example has two episodes and two subtitle languages, with short cues that make a wrong association immediately visible.

Set the association and order before naming

Write down the expected titles and episode order before opening Terminal. For this sample, the first film is the workshop introduction and the second is a demonstration about sorting fasteners. The raw file stem should include a sequence value whose text order matches the intended order. A sequence with two digits is easier to sort predictably within a run of fewer than one hundred items. Use the same number width throughout your input.

Set up a practice source folder with two ordinary local MP4 files and their SRT sidecars. Replace theirs with your own excerpts if needed. The expected sample layout has one video called 01-introduction.mp4 with 01-introduction.en.srt and 01-introduction.es.srt, and another video called 02-fasteners.mp4 with 02-fasteners.srt. The extension case is part of the script’s matching rule. The example reads lowercase MP4 and SRT extensions, with the literal suffixes shown in the filenames. This procedure neither embeds subtitles nor changes their text.

The code matches a video’s full stem followed immediately by an optional single language marker and the SRT extension. A marker is a dot and two or three lowercase ASCII letters. A name such as 01-introduction.en-US.srt falls outside that rule. So does a suffix for a caption style consisting of several dot-separated parts. If your export uses region codes or labels for descriptive captions, preserve them in the source and decide on a matching convention that distinguishes those tracks. Do not simplify meaningful labels until you know that two tracks will remain distinguishable.

A filename can match more than one rule when a video stem itself ends with a language-looking segment. For example, Lesson.en.srt could mean the English sidecar for Lesson.mp4 or the unmarked sidecar for Lesson.en.mp4. Keep those two videos and that sidecar separate from the delivery until you can establish which relationship is correct. The script refuses reused sidecars when processing an otherwise matching set. Use distinct video stems in the prepared copy, and assign each updated sidecar name to the video you verified through playback.

Make a plan in a new destination

Use Python 3.9 or later. Save the complete script at the end as pair_names.py in a scratch location. Make sure the parent of the intended output already exists and the output folder itself has not been created. The destination must sit outside the input tree. This makes it straightforward to distinguish a new delivery from the source, even when both are in a larger project folder. Python path operations.

python3 pair_names.py "/absolute/path/to/Original Episodes" "/absolute/path/to/Renamed Episodes"

The script sorts the video paths lexically. Without zero padding, a file called 10-fasteners.mp4 can come before 2-introduction.mp4 in text order. A sort order shown in Finder can also differ from text comparison. Use the full printed map to confirm episode order before you confirm any copies. The generated episode numbering starts at one, with a width of at least two digits. The source stem determines order, while the source file’s content determines whether the choice is semantically right.

For the sample, the introduction becomes Episode-01.mp4, with Episode-01.en.srt and Episode-01.es.srt. The fasteners example becomes Episode-02.mp4, with the unmarked Episode-02.srt. If the subtitle language is important, mark it consistently in the input naming convention or record it separately in a handoff note. An unmarked subtitle still belongs to an episode, but its filename cannot tell the recipient which language to expect.

Review each line and type COPY only when the association and order match your plan. Pressing Return without that exact confirmation stops before creating the output. If the script reports missing or unmatched files, read the actual filename list, including extensions. It checks immediate regular files in the source folder. An auxiliary subtitle in a subfolder or one with another extension will not enter this run, and the accepted set should be reviewed with that scope in mind.

Open the copied episodes and verify the subtitles

Open the exact copy of the first episode in VLC. Examine the available subtitle tracks and choose the intended one. If the sidecar is not selected automatically, open the corresponding SRT manually using the subtitle controls. VideoLAN documents loading external subtitles and the distinction between the video and the file containing captions and timestamps. VLC Desktop subtitle controls.

Use an audible or visible event whose expected wording you know. For the first example, the opening caption could say Welcome to the workshop. A later line might say Put the red tray beside the vise. Check that the first cue and the later cue appear around their corresponding sounds or actions, and that the displayed language matches the chosen track. Switch to the Spanish track and check that it starts with a Spanish welcome in the same scene. The player might display tracks generically, so verify the actual text when the menu label is ambiguous.

Repeat with the second video and its unmarked subtitles. The opening line could name assorted fasteners, and the later check could occur when a presenter separates wood screws and machine screws. If the opening line still welcomes people to the workshop, inspect which file VLC has loaded rather than using the number in the filename as evidence. A wrong subtitle can have plausible start times and remain readable while using words from the wrong episode.

Compare each copied MP4 and SRT with its named source using the map before preparing the final delivery. The simple script copies the entire contents as bytes. It does not recompress video, edit SRT timestamps, or convert subtitle encodings. A byte comparison catches an incomplete copy. The playback check catches an originally wrong pair whose bytes copied perfectly. For example, compare the first English track using the paths you actually chose.

cmp -s "/absolute/path/to/Original Episodes/01-introduction.en.srt" \
  "/absolute/path/to/Renamed Episodes/Episode-01.en.srt" \
  && echo "English subtitle bytes match."

Diagnose missing files, drift, and the wrong cut

If the script sees a subtitle that belongs to no MP4, inspect whether it came from a different export or is named for another cut. Do not attach it to the closest-sounding episode by guessing. Open the original video and subtitle together, then check two known cues before fixing or excluding the sidecar. If there is no subtitle for a video, decide whether that file belongs in this paired set and find the corresponding text track or take it out of the staged input.

For a subtitle with a plausible start but a growing delay, compare the full duration or two known scene transitions with the source version it was prepared for. An editorial cut can remove or add footage after the opening. A filename change cannot alter the timestamps to match that cut. Preserve the original pair, and locate the correct version before proceeding. A track whose characters look garbled deserves separate inspection in a text editor or player. VLC’s FAQ discusses encoding-related subtitle display issues. VLC subtitle troubleshooting.

If an output operation is interrupted, check the destination against the printed plan. A partly written video might open and play for the first moments, so use a byte comparison before accepting it. Retry to a fresh destination after the interrupted batch has been identified. Avoid mixing complete files from one attempt with files from another until you have checked that both runs used the same source set.

Keep a copy of the mapping next to your project notes. A short delivery receipt can name each original episode, its new ID, the expected tracks, and a checkpoint you used during playback. If the recipient reports a missing track on their player, they can manually select the exact sidecar and compare the marked cue. This gives them a way to distinguish a detection problem from an association issue without inspecting the entire source folder.

Document the episode and caption set before processing

Create a small plain-text manifest for each delivery. Record the source video name, the working sequence number you expect, the expected sidecar filenames, and the languages or purposes of the tracks. You can make this list before running the script so it provides a check independent of the filenames it proposes. The workshop example’s first line might identify the introduction, the English track, and the Spanish track. The second line can identify the fasteners video and explain that its unmarked track is English. Write down a later cue timestamp for each video if you can.

Give similarly named video edits explicit labels during preparation. A rough cut and a final cut can both have a file called Introduction in different output folders. If you gather both into one source directory, choose which cut belongs in your delivery before combining captions. Suppose the final version shortens its opening credits by seven seconds. A rough-cut sidecar can then display every line seven seconds after it should. Giving both files consistent names would make association easier while preserving the wrong schedule. Start by choosing the approved cut and checking its source pair.

If your collection has different caption purposes within a language, check whether the script’s naming rule can express what you need. An ordinary English subtitle and an English descriptive track carry different choices. The sample suffix rule fits one simple lowercase language marker, and it has no built-in marker for descriptive audio cues or forced subtitles. Keep a naming manifest that records those distinctions. Where the labels cannot be reduced without ambiguity, prepare the group under a convention designed for your player or use a smaller scratch set to practice the basic rule.

A practical source map can include the item’s actual title and duration, then the language and purpose for each caption. You can record one more field for the version supplied by the editor. That reference becomes especially useful if titles have been translated or revised after the files were exported. The copied episode names supply a clear order. The map explains which content and version each number identifies.

Rehearse an intentional mistake in a scratch folder

Start a second practice folder with copies of both videos and their sidecars. Give the English subtitle for the introduction a temporary source name that lacks its initial zero. Leave the video stem unchanged. The file will no longer match that video’s full stem. If the other introduction track is still present, the run can assemble provisional valid groups before discovering the unmatched SRT. The expected outcome is still a stop before the output is created. Read the error and inspect the exact filenames. This provides a reproducible check of what happens when a naming inconsistency enters the input.

Then restore the subtitle’s correct stem and run the preflight again. Stop at its confirmation question. Check that all expected video and SRT copies now appear in the plan. Give the scratch destination a visibly distinct label so it cannot be confused with the actual handoff. A successful second preflight is good evidence that the missing prefix caused the earlier failure. It also demonstrates that you can identify and correct a relationship before any copies are made.

Test a missing sidecar separately using copies. Move the only fasteners subtitle out of the scratch input, leaving its video. The script should report that video as missing captions. Put the subtitle back and check the plan again. These two tests address different conditions. An unmatched subtitle suggests checking extra or misnamed tracks. A video with no usable track suggests checking whether the corresponding file is present. The source review differs even though both failures keep the delivery from being created.

A more subtle test uses two validly named but intentionally swapped caption contents. Use two very short disposable SRT files that you can inspect as text. Make the introduction file contain a clearly wrong fasteners cue and give the fasteners file an obvious welcome line. Keep their filenames ones the rule accepts. The script should be able to plan the association because the stems match. During playback the spoken words and displayed cues should disagree. This is a safe demonstration of why filename validation and editorial playback review both belong in the workflow. Restore the correct copies afterward and leave the contrived set out of the final delivery.

Check two scenes and each intended language

Prepare a tiny playback checklist independent of the target names. For every episode, identify one opening cue and one later checkpoint. Choose concrete language that is easy to distinguish from another track. For the workshop opening, choose a complete sentence containing workshop. For the fasteners example, choose words about machine screws or a tray compartment. If you have English and Spanish tracks, record the expected language and one recognizable line in each. These cues should refer to distinct actions and to time positions far enough apart to reveal a drift or a cut mismatch.

When checking an SRT separately, open a copy in a plain text editor and note the time shown for the first relevant cue. A typical SRT includes a sequential cue number and a start and end time. Then seek to that time in the video and confirm that the cue belongs there. If a cue begins shortly before someone speaks for readability, compare it with your actual acceptance criteria. The goal of this short review is to catch large mistakes such as the wrong version or timing track before spending time on a full review.

Consider what language labels actually identify in your player. A file suffix can help users distinguish captions, but VLC can display generic or implementation-dependent track labels. Switch off the currently active caption, manually load your exact SRT copy when needed, and watch until a distinctive cue appears. Repeat for each intended track when the deliverable makes multiple languages available. You may also have an embedded track in the MP4. Its presence does not show that the external captions were loaded. Manually choosing the exact SRT and identifying its distinctive text gives a reliable local check.

When one track displays a valid first cue and the other seems blank, compare its actual cue timing with the current playhead. A subtitle file can have intentional silence or an offset. Check whether the plain text contains cues near the expected scene before converting encodings or rewriting times. If the later cue is also consistently wrong, first revisit the edition or filename mapping. The same visible symptom can come from a subtitle prepared for another cut, a mislabeled language, or a player using a different file.

Verify the exact set someone will receive

After checking your local output, use the intended delivery method on a small sample before sharing the complete collection. Open the copied MP4 from the receiving folder or the extracted package, then select its matching SRT. Confirm the copied name remains complete, including the language marker and extension. Some upload systems accept videos and omit unrecognized sidecars. A file listing and a direct playback check expose this early without requiring any format conversion.

If the final recipient uses a specific player or ingest tool, ask which subtitle names it recognizes and whether it can select multiple external tracks. A player that handles the plain same-stem SRT may treat language-marked tracks differently. Keep the copy with the intended names available and document manual selection for the test. Use the known cue and its expected language as the acceptance marker. A play button working for the MP4 confirms the audio and video path, while the subtitle comparison confirms the extra file was actually seen.

When retaining a delivery receipt, keep the script’s map and the playback result together. Include which episode was checked, which caption file was selected, the opening and later cues, and the version of the source cut if known. Record any unverified track as pending rather than assuming the other language proves it. If a later publication uses a changed edit, repeat the two-scene check against the new source pair before using an earlier caption delivery.

Preserve the original identifiers through later edits

If a new episode is added after a batch has been numbered, decide whether existing episode IDs need to stay stable. The script starts at one and numbers the entire input in lexical order. Inserting a new first video into a later source run would shift the names of the previously numbered copies. A distribution schedule, shared playlist, or translated caption job may already refer to those numbers. Keep a versioned copy of the earlier mapping and compare the planned output before confirming a later run.

For a revised delivery, you can stage only the final set with deliberate source prefixes that reflect the new episode order. If specific IDs must stay stable across insertions, use a workflow that applies those approved IDs explicitly rather than deriving them anew from directory order. Keep this script for closed batches where the order is set. The playback checks still apply to either process because the sidecar’s language and timing are properties of the copy you actually deliver.

Standalone pairing script

# Run: python3 pair_names.py "/path/to/originals" "/path/to/new-output"
from pathlib import Path
import re
import shutil
import sys

source, output = (Path(arg).resolve() for arg in sys.argv[1:])
if not source.is_dir() or output.is_relative_to(source) or output.exists():
    raise SystemExit("Choose a new output folder outside your input folder.")
files = [p for p in source.iterdir() if p.is_file() and not p.is_symlink()]
videos = sorted(p for p in files if p.suffix == ".mp4")
subtitles = {p for p in files if p.suffix == ".srt"}
used = set()
plan = []
for number, video in enumerate(videos, 1):
    new = f"Episode-{number:02d}"
    pattern = re.compile(re.escape(video.stem) + r"(\.[a-z]{2,3})?\.srt")
    matched = [(p, pattern.fullmatch(p.name)) for p in sorted(subtitles)]
    tracks = [(p, m.group(1) or "") for p, m in matched if m]
    if not tracks or any(p in used for p, _ in tracks):
        raise SystemExit(f"Missing or ambiguous captions for {video.name}")
    used.update(p for p, _ in tracks)
    plan.append((video, new + ".mp4"))
    plan.extend((p, new + suffix + ".srt") for p, suffix in tracks)
if not videos or used != subtitles:
    raise SystemExit("Empty video list or unmatched SRT files. Check the input set.")
for path, name in plan:
    print(path.name, "->", name)
if input("Type COPY if the episode order is correct: ") != "COPY":
    raise SystemExit("Stopped.")
output.mkdir()
for path, name in plan:
    with path.open("rb") as src, (output / name).open("xb") as dst:
        shutil.copyfileobj(src, dst)

References