Question:
How do I move files from many sub-directories with the same name to a single directory of that name. All files in multiple directories named X should get moved together into one directory named X.
Example file structure:
(The real structure is 200-300 directories at the level I've marked as 1, 2, 3, etc., with varying numbers of directories below that.)
(Note all labels like Group _ are just that--labels. The actual names are irregular.)
Disk
1
2
The goal is to have files in various sub-directories with name "Group X" moved into a single directory with name "Group X", like so:
Thanks!
You would do something like:
dest="Group A"
find -type f |
grep $dest |
while read filename
do
echo mv $filename ${dest}/$(basename $filename)
done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.