I have a directory foo
with several files:
.
└── foo
├── a.txt
└── b.txt
and I want to move it into a directory with the same name:
.
└── foo
└── foo
├── a.txt
└── b.txt
I'm currently creating a temporary directory bar
, move foo
into bar
and rename bar
to foo
afterwards:
mkdir bar
mv foo bar
mv bar foo
But this feels a little cumbersome and I have to pick a name for bar
that's not already taken.
Is there a more elegant or straight-forward way to achieve this? I'm on macOS if that matters.
foo
? Do those links now need to point tofoo/foo
? – Harper - Reinstate Monica Dec 2 at 18:56foo
(e.g. "recently opened files"). To keep those working,foo
itself has to be moved, rather than just its content. (otherwise those links would refer to the new parent directory which isn't desired) – Stefan Dec 2 at 22:18mkdir foo/foo; mv foo/* foo/foo
prints an error but still results in your expected outcome (at least on Ubuntu). Now: if you are interested on how inodes "move" then the result is not what you want (the originalfoo
directory is not the innerfoo
so if you access via inode or something you will not find the expected structure). – Giacomo Alzetta Dec 3 at 11:38