In linux I'm hoping to create a dynamic virtual directory... maybe hard to explain in text I hope that the graphic here makes since.
I want to use the following directory content to create a couple of extra directories that stay up to date as the files in the source directory.
/home/<user>/SRC_Directory
1.txt
1.src
2.txt
3.txt
4.src
2.jpg
2.abc
I'd like the files in the directory above to auto break out to something like the sample below as files are added to the SrcDirectory. Also having the broken out files be symlinks back to the files in the main directory so that I have a full directory with all files, and don't take up large amounts of file space.
/home/<user>/TxtFilesOnly
1.txt
2.txt
3.txt
/home/<user>/ABCFilesOnly
2.abc
/home/<user>/JPGFilesOnly
2.jpg
/home/<user>/SRCFilesOnly
1.src
4.src
Here's an example to get you started:
cd /home/SRC_Directory
for file in *; do
ext=${file#*.} # get the extension, by stripping everything up to a "."
ext_upper=${ext^^}
target_dir=/home/${ext_upper}FilesOnly
mkdir -p "$target_dir"
[ -e "$target_dir/$file" ] || ln -s "$PWD/$file" "$target_dir/"
done
I hope the steps are self-explanatory, and you will be able to customize to your need.