Create Folders Then Move Files into Folders

How do I make new folders with the name of all the files in a folder without the file extension in the folder name, then move the files in to there corresponding folder in Fedora 24 Linux?

Example:

File0.mp4
File1.mp4

Folders created:
File0
File1

Then move files in to folders.

Suggested Answer:

Manually

mkdir File0 File1
mv File0.mp4 File0
mv File1.mp4 File1

Automated Bash Script

#!/bin/bash

# change to your directory name

yourdir="/export/home/nails/s1"
cd $yourdir

# find files ONLY IN THE CURRENT DIRECTORY
# then foreach file remove the extension and make the directory from 
# that name. finally move the file to that directory

find . ! -name .  -prune -type f| while read myfile

do
   noext=${myfile%.*} # remove the extension
   mkdir -p $noext    # make the directory if it doesn't exist
   mv $myfile $noext  # move the file to the directory
done

Linux Tips

See Also
Explain File System

Have a Linux Problem
Linux Forum - Do you have a Linux Question?

Linux Books
Linux Certification, System Administration, Programming, Networking Books

Home Index
Linux System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.