Given a directory with these files for example.
bike.png
car.jpg
comedy.mov
error.log
horror.avi
info.txt
interview.mp3
song.flac
tree-small.jpeg
11.10.2017_y
some-directory
nested-file.log
I am trying to write a bash script that would create 3 folders "Music, Videos, Images" and organize these files into their type folder and deletes .log files.
Music is all flac/mp3 files, Images are jpeg/png files, and Videos are all avi/mov files.
The final directory structure should look like this.
images/
bike.png
car.jpg
music/
interview.mp3
song.flac
videos/
comedy.mov
horror.avi
info.txt
tree-small.jpeg
11.10.2017_y
some-directory/
nested-file.log
>Solution :
Wouldn’t this do it?
#!/bin/sh
mkdir music videos images
mv *.flac *.mp3 music/
mv *.jpeg *.png images/
mv *.avi *.mov videos/
rm *.log