Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Linux command/script help

Name: Anonymous 2011-10-06 15:10

Okay, I'm comfortable with the basic linux commands such as cp, mv, mkdir, etc., but now I want to do something more challenging and I don't know where to start so I'm turning to /prog/ for help.

I have just under five hundred films in a directory, and I want to point XBMC to this directory and have it catalog the films for me.  In order to do this though each film file needs to be in a subdirectory with the same name.  So what I want to do is to create a command, or a script, to look at a file such as "Kill Bill Volume 1.avi" and create a directory with the same name, and then move the file into the directory, so that I end up with a directory called "Kill Bill Volume 1" and the avi file inside of that.  I'd like the command (or script) to do this for each file in the directory.

Any ideas on how I would automate this?  Can I create a command to do it, or do I need to write a script?  Any ideas on where to start?  I cannot face doing this by hand for all 500 files.

...also as an aside - am I going the right way by using XBMC to set up my media centre?  Are there any better alternatives I should look at?

Name: Anonymous 2011-10-06 15:11

why do you want to complicate things and put each file in its own directory?

Name: Anonymous 2011-10-06 15:14

Using Bash, in the same directory where you have the avi files:


for i in *.avi; do       # Loop, fill i with stuff from *.avi in each step
    mkdir "${i%.avi}"    #Make directory: i minus .avi suffix
    mv "$i" "${i%.avi}"  #Move file in i into its directory
done

Name: Anonymous 2011-10-06 15:14

>>3
DON'T HELP HIM!!!

Name: Anonymous 2011-10-06 15:16

>>2
I read that XBMC requires each file to be in it's own directory, and it uses the directory names to try to match the movie to an entry in IMDB or something.

>>3
Thanks, I'll give this a try now.

Name: Anonymous 2011-10-06 15:22

>>3
Worked perfectly, thanks!  I really need to learn how to do this stuff.

Name: Anonymous 2011-10-06 15:44

Name: Anonymous 2011-10-06 18:05

>>7
I'm >>3 and >>4; I felt I was being too nice so I had to compensate.

Name: HAXUS THE SAGE 2011-10-07 0:29

Not /prog/ related. GTFO!

Name: Anonymous 2013-08-31 17:55


Why is everyone being mean to him? Is it really so bad to put your hand on someone's ass now?

Name: Anonymous 2013-08-31 19:26



And sometimes because they're assuming that since the game is made by a filthy westerner, it's going to be full of shit and overused jokes.

Don't change these.
Name: Email:
Entire Thread Thread List