mvedit


Name

mvedit - edit a recursive directory listing to rename (and delete) files

Synopsis

mvedit --help

mvedit [--case-sensitivity value] [--delete] [--dirs] [--editor editor] [--maxdepth levels] [--verbose]

Description

mvedit lets you edit the output of recursive directory listing (same as with ls -1aR) and thus rename a great number of files in a convenient fashion.

Just start the script in the directory where you want to rename files. Your editor will start up, showing the file list. Directories are introduced with their names and a trailing colon. These lines, blank lines, and the lines for the current and the parent directory must not be changed. All other lines may be edited. If the --delete switch is specified, file may be deleted by emptying out their line. If you save the file and quit your editor, the script will start asking you for confirmations of the renames and deletions before performing them. If you answer with `a' (for always) at the confirmation prompt, all remaining renames and deletions will be performed unconditionally and automatically.

If the scripts detects problems with your new names (e.g., if the new names are not unique) it will abort, reporting a reason, a location of the error, and a file name. You may then try to correct your error and start over by running mvedit again and reading in the old file's contents in your editor.

Options

--case-sensitivity value
Define whether the underlying file system is considered as case sensitive or not. The value argument can be `on' for case sensitive file systems, `off' for case insensitive file systems, and `auto' to make the script try to detect case sensitivity itself (this is the default).

For case insensitive file systems, mvedit's overwrite checks are different and renames only differing in case are performed using intermediate files (note that with file systems like FAT two files that only differ in case may not exist, yet the case of each single file name is stored).

There is only a single setting of case sensitivity for each run of mvedit regardless of whether different file systems are crossed. For the automatic check, the case sensitivity of the file system of the current directory is tested against.

--delete
Enable file deletion by emptying - not deleting! - lines. Directory deletion is not yet supported.
--dirs
Only rename directories.
--help
Print help on options.
--editor editor
Use editor to edit the file listings. If this option is not given, the editor defaults to the one specified with environment variable EDITOR or vim.
--maxdepth levels
Descend at most levels (a positive integer) levels of directories below the current working directory. For levels equal to 1, only rename files / directories in the current working directory.
--verbose-v
More verbose output.

Bugs and Caveats

While mvedit does allow to swap file names (e.g., renaming a to b and vice versa) it will perform such renames in multiple steps, moving a file out of the way whenever it would be overwritten. Thus, if mvedit aborts while renaming - for example because of missing permissions - the directory tree may be in an `inconsistent' state where certain files are already renamed but not to their intended target name. Typically, this will be the original name with the last character replaced by a tilde.

Also, if you rename something to an existing target name the target will be renamed implicitly even if you have specified no renaming (or, under the --dirs option, have not even seen that the target exists). The positive effect is that the script should not overwrite something silently. On the other hand it does not yet warn if this situation occurs.

The script is not very file-system aware (cf. --case-sensitivity above) and will not guard against illegal character or too long file names.

Directory deletion is currently not supported.

Copyright

(C) 2002-2006 Mark Hillebrand .

This code is released under the BSD License. Before using this software, visit http://www.opensource.org/licenses/bsd-license.php for the full license text.

Download

Page MoveEdit
Revision 12 Feb 2006
Parents: Index