switch-link —
retarget symlinks based on the extension of their
targets
switch-link |
[Nv] oldext
newext |
The switch-link utility examines all the
symlinks in the current directory and its subdirectories, looking for those
whose targets end in the .oldext extension as
specified on the command line. If any of those are found, they are changed
to point to a target with the same base name and a
.newext extension as specified on the command line.
This is useful in some setups when such symlinks are used to provide
different images for different situations, e.g. holiday decoration.
Options:
-h
- Display a usage message and exit.
-N
- No-operation mode; just display what would have been done.
-V
- Display program version information and exit.
-v
- Verbose operation; display diagnostic messages.
The switch-link utility exits 0 on
success, and >0 if an error occurs.
The switch-link utility's operation is
currently not directly affected by its environment.
The switch-link utility examines the
current directory and all its subdirectories, and its operation is not
further affected by any files.
Change all the symlinks pointing to
*.nonch to point to the same file, but with a
.ch extension:
switch-link nonch ch
See what switch-link would do without
actually changing any links:
switch-link -N nonch ch
The switch-link utility was written by
Peter Pentchev in 2010.
Peter Penchev
⟨roam@ringlet.net⟩
- *
- Create a temporary file containing the list of links to avoid weird
security-like issues or plain old incorrect operation resulting from
whitespace in the link's name.