LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-20-2012, 04:05 PM   #1
MidKnightLoki
LQ Newbie
 
Registered: Nov 2012
Posts: 1

Rep: Reputation: Disabled
Script to sort video files into different folders


I have a downloads folder that gets many different files from different sources (mostly videos) I am also using XBMC as my Media Center I am trying to create a script that will move all related files to the same folder.

Ex. ~/Videos folder may contain a file called My.Show.s04e06.mkv
in the same folder there may be another file called myshows04e07.avi

I would like both of the above files to go to a folder called ~/Videos/Shows/MyShow so that it will be easy to find in XBMC

I have been using Bash and various combinations of ls, find, and mv commands but I cant seem to get it it to work.

I am fairly new to Linux but I do have some basic knowledge of scripting and programming so I am just looking for someone to point me in the right direction.

Thanks
 
Old 11-20-2012, 06:49 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,564
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
Code:
#!/bin/sh --
find ~/Videos -type f \( -iname \*.mkv -o -iname \*.avi -o -iname \*.m4v -o -iname \*.divx -o -iname \*.mpg -o -iname \*.flv -o -iname \*.mov -o -iname \*.wmv -o -iname \*.3gp \) -print0 | xargs -0 -iX mv 'X' ~/Videos/Shows/MyShow
exit 0
Next time please post what you got instead of saying "doesn't work". Existing (pseudo) code shows you've tried, making improving it both efficient and a learning experience.
 
  


Reply

Tags
bash script $@, file manager, mediacenter, shell scripting, xbmc


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to sort files based on part of file name valunthar Linux - Software 8 06-26-2011 04:56 AM
Need help with script to organise files into folders as part of DVD backup script jasybee2000 Linux - Newbie 5 06-15-2009 08:29 PM
script to sort files according to timestamp aeby Linux - Newbie 1 05-16-2007 09:18 AM
Bash script to sort image files dtcs Programming 5 09-26-2006 10:50 PM
bash script to sort files by extension otheralex Programming 7 08-19-2005 03:40 AM


All times are GMT -5. The time now is 02:13 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration