Struct MatchArgs

Source
pub struct MatchArgs {
    pub path: PathBuf,
    pub dry_run: bool,
    pub confidence: u8,
    pub recursive: bool,
    pub backup: bool,
    pub copy: bool,
    pub move_files: bool,
}
Expand description

Arguments for AI-powered subtitle file matching and renaming.

This structure defines all command-line options available for the match subcommand, which uses artificial intelligence to analyze video and subtitle files and automatically rename subtitles to match their corresponding videos.

§Operation Modes

  • Normal Mode: Performs actual file operations
  • Dry Run Mode: Simulates operations without making changes (--dry-run)
  • Recursive Mode: Processes subdirectories (--recursive)
  • Backup Mode: Creates backups before renaming (--backup)
  • Copy Mode: Copy matched subtitle files to video folders (--copy)
  • Move Mode: Move matched subtitle files to video folders (--move)

§AI Matching Process

  1. Scans the target directory for video and subtitle files
  2. Extracts content samples from both file types
  3. Uses AI to analyze content similarity
  4. Matches files based on confidence threshold
  5. Renames subtitle files to match video file names
  6. Optionally relocates subtitle files to video directories

§Examples

# Basic matching in current directory
subx match ./videos

# Dry run with high confidence threshold
subx match ./videos --dry-run --confidence 90

# Recursive matching with backup and copy to video folders
subx match ./media --recursive --backup --copy

Fields§

§path: PathBuf

Target directory path containing video and subtitle files.

The directory should contain both video files and subtitle files that need to be matched and renamed. Supported video formats include MP4, MKV, AVI, etc. Supported subtitle formats include SRT, ASS, VTT, etc.

§dry_run: bool

Enable dry-run mode to preview operations without making changes.

When enabled, the command will analyze files and show what operations would be performed, but won’t actually rename any files. This is useful for testing matching accuracy before committing to changes.

§confidence: u8

Minimum confidence threshold for file matching (0-100).

Only file pairs with similarity confidence above this threshold will be matched and renamed. Higher values result in more conservative matching with fewer false positives, while lower values are more aggressive but may include incorrect matches.

  • 90-100: Very conservative, highest accuracy
  • 80-89: Balanced approach (default)
  • 70-79: More aggressive matching
  • Below 70: Not recommended for automatic operations
§recursive: bool

Recursively process subdirectories.

When enabled, the matching process will descend into subdirectories and process video and subtitle files found there. Each subdirectory is processed independently, so files are only matched within the same directory level.

§backup: bool

Create backup copies of original files before renaming.

When enabled, original subtitle files are copied to .bak files before being renamed. This provides a safety net in case the matching algorithm makes incorrect decisions.

§copy: bool

Copy matched subtitle files to the same folder as their corresponding video files.

When enabled along with recursive search, subtitle files that are matched with video files in different directories will be copied to the video file’s directory. This ensures that media players can automatically load subtitles. The original subtitle files are preserved in their original locations. Cannot be used together with –move.

§move_files: bool

Move matched subtitle files to the same folder as their corresponding video files.

When enabled along with recursive search, subtitle files that are matched with video files in different directories will be moved to the video file’s directory. This ensures that media players can automatically load subtitles. The original subtitle files are removed from their original locations. Cannot be used together with –copy.

Implementations§

Source§

impl MatchArgs

Source

pub fn validate(&self) -> Result<(), String>

Validate that copy and move arguments are not used together

Trait Implementations§

Source§

impl Args for MatchArgs

Source§

fn group_id() -> Option<Id>

Report the ArgGroup::id for this set of arguments
Source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

impl Debug for MatchArgs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromArgMatches for MatchArgs

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,