Move into folders

Often when you download something, for instance movies, it is a big pack of many movies, and they are all in one folder as .avi files or something like that. You might want all of those in their own separate folder to use with f.ex. XBMC, and it can be a tedious task to make a folder for each movie, and move them into that folder.

Well here is the script to do it, filled with comments to explain what is happening. Hope someone finds it useful.

First: This is the quick and dirty oneliner to do it if you are sure there are only files with extensions in the dir, it’s without any error-checking:
IFS=$’n’;for f in `ls -1`; do mkdir “${f%.*}”;mv “${f}” “${f%.*}/”;done

The whole script is attached, with an abundance of comments describing what’s happening.

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: