You are not logged in.
Pages: 1
I really need to get a good book to read and learn some bash scripting so I can do this myself. but this is only the 3rd or 4th time i've come here asking
I was hoping someone might be able to assist me again
I'm trying to organize my movie folder again. I've let it go too long
basically, i'm looking for a bash script to go through my folder of movies. each movie has it's own folder with an avi, jpg and nfo. I need the files in the folders to be the same name as the parent folder
so lets say i have this
movie title folder (2012)
-movie_file_2012.avi
-an_nfo_file.nfo
-a_jpg.jpg
I want to turn into this
movie title folder (2012)
-movie title folder (2012).avi
-movie title folder (2012).nfo
-movie title folder (2012).jpg
anyone?
this is a signature
Offline
Maybe this will point you in the right direction http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-12.html
Offline
I really need to get a good book to read and learn some bash scripting so I can do this myself. but this is only the 3rd or 4th time i've come here asking
I was hoping someone might be able to assist me again
I'm trying to organize my movie folder again. I've let it go too long
basically, i'm looking for a bash script to go through my folder of movies. each movie has it's own folder with an avi, jpg and nfo. I need the files in the folders to be the same name as the parent folder
so lets say i have this
movie title folder (2012)
-movie_file_2012.avi
-an_nfo_file.nfo
-a_jpg.jpgI want to turn into this
movie title folder (2012)
-movie title folder (2012).avi
-movie title folder (2012).nfo
-movie title folder (2012).jpganyone?
I won't do the work for you, but if you're willing to look things up and try to write a working script that does what you've described--I'll be happy to help flush out problem areas.
Okay, so what you want is to turn
Movies/:
A-Movie-I-love.avi
A-Movie-I-love.nfo
A-Movie-I-love.jpg
A-Movie-about-Llamas.avi # :P
A-Movie-about-Llamas.nfo
A-Movie-about-Llamas.jpg
into this:
Movies/:
A-Movie-I-love/:
A-Movie-I-love.avi
A-Movie-I-love.nfo
A-Movie-I-love.jpg
A-Movie-about-Llamas/:
A-Movie-about-Llamas.avi
A-Movie-about-Llamas.nfo
A-Movie-about-Llamas.jpg
right?
Last edited by lspci (2013-04-23 20:40:30)
Offline
Just use vidir with */* and a substitution command like this:
:%s_\t\([^/]*\)/[^.]*\._\t\1/\1.
In this case _ is the substitution argument delimiter.
It matches: TAB (used in file list by vidir), store pathname as pattern 1, path separator, filename with dot.
And replaces with: TAB, pathname (pattern 1), path separator, pathname (pattern 1) with dot.
Offline
cd /path/to/movie/folder
for file in ./*; do
cd "$file"
[ `ls *.nfo | wc -l` -eq 1 ] && mv *.nfo "$file.nfo" || echo "multiple nfo: $file"
[ `ls *.jpg | wc -l` -eq 1 ] && mv *.jpg "$file.jpg" || echo "multiple jpg: $file"
[ `ls *.avi | wc -l` -eq 1 ] && mv *.avi "$file.avi" || echo "multiple avi: $file"
cd "$OLDPWD"
done
perl-rename and/or sed can probably do this quicker, but ... I know how to do this with mvs ... so mvs it is.
also, notice how I'm just 'mv'-ing them ... If I screwed up somewhere(though I don't think, and I hope I haven't) you might end up losing your movies completely. So ... make sure you've got em backed up before running this.
Offline
@pbhandari
that worked perfectly for me.
I've never been able to wrap my head around the syntax's when it comes to scripting. I can work my way around the shell fine manually, and I can make out what that script is doing for the most part, but I've never been able to write those from scratch
this is a signature
Offline
@ssl6
no problem, glad I could help.
Offline
also, notice how I'm just 'mv'-ing them ... If I screwed up somewhere(though I don't think, and I hope I haven't) you might end up losing your movies completely. So ... make sure you've got em backed up before running this.
Adding the "-i" option to the mv's might help make this safer. Other than typing "n", you also get a chance to abort everything with Ctrl-C.
Officer, I had to drive home - I was way too drunk to teleport!
Offline
Pages: 1