In a directory I have the following files:
lebron_2018.txt lebron_2019.txt
melo_2018.log melo_2019_01.log
wade_2018.bak wade_2019_02.jpg
All the files has delimiter of "_", I would like to copy the files to different new directory according to the prefix. For example
lebron_2018.txt lebron_2019.txt will copy to \backup\lebron
melo_2018.log melo_2019_01.log will copy to \backup\melo
wade_2018.bak wade_2019_02.jpg will copy to \backup\wade
I can do it by cp lebron*.* \backup\lebron. But can it be done by searching the filename, and copy to the folder according to their filename automatically?