I have a relatively simple but time consuming task of moving certain files to designated folders.
Example File names:
01234567.Description.Date.FileExtension
89ABCDEF.Description.Date.FileExtension
Example Folders:
01234567
89ABCDEF
All are within a folder, I just want a script that reads the first portion of the name of the file up to the period . and move that file to the matching folder.
I have tried the following solution link but I think @Thomas-The-Bombest answer below should be enough to manipulate it to do what I'm trying to achieve. Thank you
You can use
cut -d. -f1to grab the whatever is before the first.Simply store this in a variable and use it to name a folder with the
mkdircommandi.e.
$folderName = echo 01234567.Description.Date.FileExtension | cut -d. -f1mkdir /path/to/wherever/$folderName