vidir
Edit directory contents in a text editor
TLDR
Edit the contents of the specified directories
Display each action taken by the program
Edit the contents of current directory
Use the specified text editor
Read a list of files to edit from stdin
SYNOPSIS
vidir [options] [directory ...]
vidir - [file ...]
PARAMETERS
-
Reads a list of file paths from standard input or command line arguments instead of scanning a directory. This allows vidir to operate on a custom set of files.
--dry-run
Shows the commands that would be executed without actually performing any file system modifications. This is highly recommended for reviewing changes before committing them.
--no-sync
Disables fsyncing of the temporary file before opening the editor. This is generally not recommended as it might lead to data loss if the system crashes before the editor flushes its changes, but can offer minor performance gains on some systems.
--help
Displays a concise help message detailing usage and options, then exits.
--version
Prints the version information for vidir and exits.
DESCRIPTION
vidir is a powerful utility that allows you to manage files and directories by editing their names and structure directly within your preferred text editor. When invoked, it generates a temporary file containing a list of all items (files and subdirectories) in the specified directory, or the current directory if none is given.
This list is then opened in your EDITOR (or VISUAL) environment variable's assigned editor. You can rename files by changing their names, delete files by removing their lines, and even reorder them (though reordering doesn't directly affect the filesystem, it can help organize your editing task). Upon saving and exiting the editor, vidir parses the modified list and performs the necessary file operations (renames, deletions, or creations for new directories), providing a batch-like interface for filesystem manipulation. It's especially useful for renaming many files consistently or performing complex cleanup tasks interactively.
CAVEATS
Caveats and Limitations:
vidir requires a text editor to be defined in the EDITOR or VISUAL environment variables; otherwise, it will fall back to a default like vi.
Changes are applied irreversibly upon saving and exiting the editor, unless the --dry-run option is used. Exercise caution.
Deleting a line in the editor will result in the corresponding file or directory being deleted on the filesystem.
While you can rename files to include new directory components (e.g., 'file.txt' to 'newdir/file.txt'), directly moving files between *existing* distinct subdirectories by changing their paths in the editor is not supported, as vidir primarily operates on the context of its initial directory scan.
ENVIRONMENT VARIABLES
vidir heavily relies on the EDITOR or VISUAL environment variables to determine which text editor to open. If neither is set, it typically defaults to vi. Setting these variables to your preferred editor (e.g., export EDITOR=nano or export VISUAL=code --wait) is crucial for vidir to function as expected with your workflow.
BATCH OPERATIONS
One of vidir's most significant strengths is its ability to facilitate batch operations. Instead of executing multiple mv, rm, or mkdir commands individually, you can consolidate all your changes into a single editing session. This allows for a visual review of all intended modifications before applying them instantly, significantly reducing the chance of errors in repetitive or complex file management tasks.
HISTORY
vidir is a prominent utility within the moreutils package, a collection of small, yet powerful and useful Unix utilities. It was created by Joey Hess, the package's maintainer, with the aim of providing an intuitive and interactive way to manage files and directories that goes beyond typical command-line tools. Its development continues as part of the moreutils project, ensuring its adaptability and relevance in modern Linux environments.