I often run into the following situation. I am in a directory with several sub-directories like so
$ls a b c d
I would like to archive directories
a-d by moving them into a new directory at the same level called
$ls archive $ls archive a b c d
The way I currently do this is to make
archive and then do a move all. I don’t like this though because you always get the error `mv: cannot move ‘archive’ to a subdirectory of itself, ‘archive/archive’. While this works I don’t like the fact I am ‘abusing’ the built-in exception handling.
$mkdir archive $mv * archive/ `mv: cannot move 'archive' to a subdirectory of itself, 'archive/archive'
Ideally I would like a solution that does not involve errors. Something along the lines of mv automatically creating the directory but unfortunately that does not work.
$mv * archive/ mv: target 'archive/' is not a directory