Re: Moving Only Sub-Directories?

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

 



If I understand correctly, you have a source folder with a large mix of files and directories, but you only want to move the directories (and the files & sub-directories within them), not the files at the root level of the source. And you have enough files/directories to make Lynx's dir-ed mode a pain. If so, I'd use "find" to pull the directories and move them:

 find /path/to/source/ -maxdepth 1 -mindepth 1 -type d

That should generate a list of just the directories to be moved so that you can review them. You can then tell "find" to move those files:

find /path/to/source/ -maxdepth 1 -mindepth 1 -type d -exec mv {} /path/to/dest/ \;

The "-maxdepth 1" prevents "find" from trying to go into sub-directories to move their contents (after they've been moved). I'm not sure if you need this.

The "-mindepth 1" prevents "find" from returning the current directory "." because that triggers an error.

The "-type d" instructs "find" to only evaluate directories.

The "-exec mv {} /path/to/dest \;" (note the backslash before the command-terminating semi-colon) is the command to be executed on each resulting file, replacing the "{}" with the file-path that "find" is considering.

Hope this helps,

-tim


_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list

[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]