coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Feature request: "mv --relative" or "mv -r"


From: Daniel Böhmer
Subject: Feature request: "mv --relative" or "mv -r"
Date: Sat, 24 Nov 2018 07:42:57 +0100
User-agent: Roundcube Webmail/1.3.1

Hello,

I want to propose a new parameter to the "mv" command which
helps when working with nested directory structures from the
structure's root dir as $PWD.

Similar to the "ln" command's "--relative" parameter "mv"
could accept this and either chdir to the moved files
location beforehand or (maybe better) calculate the
target location from the given path as relative path
from the file's original location.


Examples with the "-v" switch for illustration:

$ mv -rv foo/bar.txt baz.txt
'foo/bar.txt' -> 'foo/baz.txt'

$ mv -rv foo/*.txt subfolder/
'foo/bar.txt' -> 'foo/subfolder/bar.txt'
'foo/baz.txt' -> 'foo/subfolder/baz.txt'

I often miss this switch for these use cases:

- simply rename a file in a [sub*]directory

- move a bunch of files around in a lower part of the directory structure


I find the alternatives

- mv very/long/path/{a.txt,b.txt}

- rename 's/a\.txt/b.txt/' very/long/path/a.txt

rather cumbersome to type. For the source location
I want to use bash completion and for the target
location I'd like to type only the new information,
i.e. the subfolder or the new filename.

Do you know of any easier existing ways to achieve
the desired behavior?

With some googling I could not find a previous
proposal of such a feature. Would you consider
releasing this?

Would anyone implement this? I am not a C programmer.
Although I could provide a proof of concept as a
Pull Request it would probably need some advice of
an experienced C programmer.

Kind regards
Daniel Böhmer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]