Before starting, it is recommended to have a backup of the files you are planning to modify (if possible). I recently found myself needing to move files into a folder with the same name, but found it would take longer than I wanted, I also couldn’t be bothered taking the time to create and name each folder.
- CD into the folder with your files
- Run the below code by pasting it into terminal
Line 1: Loop over all (*) the files in the current directory.
Line 2: If the item found is a file, continue.
Line 3: Makes directory with the filename without extension.
Line 4: Moves the file into the newly created directory.
After running the above code, you should end up with something like this in terminal:
Which result in your folder now looking like this: