markmv - v1.26.2
    Preparing search index...

    Class PathUtils

    Utility class for path manipulation and resolution operations.

    Provides comprehensive path handling for markdown file operations including relative path updates, home directory resolution, and cross-platform compatibility.

    Path resolution

    // Resolve various path formats
    PathUtils.resolvePath('~/docs/file.md'); // Home directory
    PathUtils.resolvePath('../guide.md', '/current/dir'); // Relative
    PathUtils.resolvePath('/absolute/path.md'); // Absolute

    Relative path updates for moved files

    // When moving a file, update its relative links
    const originalLink = '../images/diagram.png';
    const updatedLink = PathUtils.updateRelativePath(
    originalLink,
    'docs/guide.md', // old file location
    'tutorials/guide.md' // new file location
    );
    // Result: '../../docs/images/diagram.png'
    Index

    Constructors

    Methods

    • Resolve a path that may be relative, absolute, or use home directory notation.

      Parameters

      • path: string

        The path to resolve (supports ~/, relative, and absolute paths)

      • OptionalbasePath: string

        Optional base directory for relative path resolution

      Returns string

      Resolved absolute path

        PathUtils.resolvePath('~/docs/file.md');
      // Returns: '/Users/username/docs/file.md'

      PathUtils.resolvePath('../file.md', '/current/working/dir');
      // Returns: '/current/working/file.md'
    • Convert an absolute path back to a relative path from a base directory

      Parameters

      • absolutePath: string
      • fromDir: string

      Returns string

    • Update a relative path when a file is moved

      Parameters

      • originalLinkPath: string
      • sourceFilePath: string
      • newSourceFilePath: string

      Returns string

    • Update a Claude import path when a file is moved

      Parameters

      • originalImportPath: string
      • sourceFilePath: string
      • newSourceFilePath: string

      Returns string

    • Normalize path separators for cross-platform compatibility

      Parameters

      • path: string

      Returns string

    • Check if a path is within a given directory

      Parameters

      • filePath: string
      • directoryPath: string

      Returns boolean

    • Generate a unique filename if a file already exists

      Parameters

      • desiredPath: string

      Returns string

    • Validate that a path is safe for file operations

      Parameters

      • path: string

      Returns { valid: boolean; reason?: string }

    • Extract directory depth from a path

      Parameters

      • path: string

      Returns number

    • Find common base directory for multiple paths

      Parameters

      • paths: string[]

      Returns string

    • Convert Windows paths to Unix-style for markdown links

      Parameters

      • path: string

      Returns string

    • Get file extension with fallback handling

      Parameters

      • path: string

      Returns string

    • Check if path represents a markdown file

      Parameters

      • path: string

      Returns boolean

    • Safely join paths, handling edge cases

      Parameters

      • ...parts: string[]

      Returns string

    • Check if a path is a directory

      Parameters

      • path: string

      Returns boolean

    • Check if a path looks like a directory (ends with / or )

      Parameters

      • path: string

      Returns boolean

    • Resolve destination path when target might be a directory If destination is a directory, preserves the source filename

      Parameters

      • sourcePath: string
      • destinationPath: string

      Returns string