markmv - v1.41.7
    Preparing search index...

    Class FileOperations

    Core class for performing markdown file operations with intelligent link refactoring.

    This class provides the main functionality for moving, splitting, joining, and merging markdown files while maintaining the integrity of cross-references and links.

    Basic file move

    const fileOps = new FileOperations();
    const result = await fileOps.moveFile('old.md', 'new.md');

    if (result.success) {
    console.log(`Successfully moved file and updated ${result.modifiedFiles.length} references`);
    } else {
    console.error('Move failed:', result.errors);
    }

    Dry run with verbose output

    const fileOps = new FileOperations();
    const result = await fileOps.moveFile('docs/guide.md', 'tutorials/guide.md', {
    dryRun: true,
    verbose: true
    });

    // Preview changes without actually modifying files
    result.changes.forEach(change => {
    console.log(`${change.type}: ${change.filePath} - ${change.description}`);
    });
    Index
    • Move a file (markdown, or a non-markdown asset such as an image) and update all links that reference it.

      This method performs an intelligent move operation that:

      1. Validates the source and destination paths
      2. Discovers all files that link to the source file
      3. Updates all cross-references to maintain link integrity
      4. If the source is markdown, also updates any links inside the moved file itself
      5. Optionally performs a dry run to preview changes

      A non-markdown source (an image, for example) is moved as-is; only the markdown files that link to it are updated, since it has no markdown links of its own to refactor.

      Parameters

      • sourcePath: string

        The current path of the file to move

      • destinationPath: string

        The target path (can be a directory)

      • options: MoveOperationOptions = {}

        Configuration options for the move operation

      Returns Promise<OperationResult>

      Promise resolving to detailed operation results

      const fileOps = new FileOperations();

      // Simple move
      await fileOps.moveFile('docs/old.md', 'docs/new.md');

      // Move to directory (filename preserved)
      await fileOps.moveFile('guide.md', './docs/');

      // Move a linked image, updating any markdown files that reference it
      await fileOps.moveFile('image.png', 'assets/image.png');

      // Dry run with verbose output
      const result = await fileOps.moveFile('api.md', 'reference/api.md', {
      dryRun: true,
      verbose: true
      });
    • Validates the links in every file an operation modified or created, skipping any that no longer exist on disk. A failure during validation is reported in the result rather than thrown.

      Parameters

      Returns Promise<{ brokenLinks: number; errors: string[]; valid: boolean }>

      Whether the files are free of broken links, with the number of broken links and an error message for each.