I'm currently trying to organize several thousand files which are named according to what's in them, and the various "tags," if you will, are separated by spaces. So, for example:
I'm relatively new to Linux/Unix, and was wondering if there was a way to iterate through every file, create folders based on the tags, and copy the files to those folders?
So we'd end up with:
./foo_bar bar_foo.txt ./foo_bar/foo_bar bar_foo.txt ./bar_foo/foo_bar bar_foo.txt
So far, I've been manually doing everything like this:
mkdir foo_bar cp *foo_bar* foo_bar/ mkdir bar_foo cp *bar_foo* bar_foo/ ...
Obviously this is pretty time-inefficient, so I'm just looking for a way to automatically do it.
Edit: Some more examples:
./a b c d.txt ./b a d.txt ./c d e.txt ./d a.txt
All original files still in parent directory, plus: ./a/a b c d.txt ./a/b a d.txt ./a/d a.txt ./b/a b c d.txt ./b/b a d.txt ./c/a b c d.txt ./c/c d e.txt ./d/a b c d.txt ./d/b a d.txt ./d/c d e.txt ./d/d a.txt ./e/c d e.txt