Hello, just assume that you have bunch of files like below and you want to categorize these files by extensions.
( I have created these files with touch command to have a few files with extensions. If you realize, all of file size are 0)
If file extension is .mp3 ==> Move file to Music folder in current path.
If file extension is .avi ==> Move file to Video folder in current path.
If file extension is .jpeg ==> Move file to Photo folder in current path.
If file extension is not above ==> Move file to Other folder in current path.
Let’s create categorize_files.sh file and give permission to the file. Then open it with vi editor like below.
Please analyze the code below;
Run the script and check folder structure after;
Yeap! All files are moved according to task.