A movie Renamer

Hello G.s,

I am trying to develop “A movie renamer” in ruby and wanted to get some
ideas on Object oriented design, this is my first time with an Object
Oriented language so it would really help me if somebody would help me
design my application. The kind of things which I want to accomplish
are:

  • Renaming movie files in a directory from a format like
    “The.Passion.Of.The.Christ.2004.UNCUT.720p.BRRip.x264.AC3.dxva-HDLiTE”
    to a
    Good looking movie name “The Passion of the Christ”
  • If this goes well then would like to add year also along with the
    movie
    name.

Couple of things which I want to achieve by developing this is to
understand
TDD(so yes I want to write tests for my application), Object Oriented
design. It would be great if somebody can mentor me also in my pet
project.

Mayank K. wrote in post #1008259:

  • Renaming movie files in a directory from a format like
    “The.Passion.Of.The.Christ.2004.UNCUT.720p.BRRip.x264.AC3.dxva-HDLiTE”
    to a
    Good looking movie name “The Passion of the Christ”
  • If this goes well then would like to add year also along with the
    movie
    name.

hi Mayank -

take a look at the String methods (
class String - RDoc Documentation ) and regular
expressions (Regexp) ( Ruby Regexp Class - Regular Expressions in Ruby )

i would think some important things that you’ll want to think about
are whether you want to write something brutish, where you enter an
array of new names and the thing blindly renames files in a directory
(probably not what you want, as you could just rename files manually for
all that it’s worth,) and if not, whether the format <<like
“The.Passion.Of.The.Christ.2004.UNCUT.720p.BRRip.x264.AC3.dxva-HDLiTE”>>
is something consistent enough that you could take existing filenames
and modify them (using String#split, or a regex for example,) or if
you’ve got to dig into tags or other data sources in order to rename the
files.

It would be great if somebody can mentor me also in my pet
project.

this is a great forum for getting helpful replies to specific
questions. my suggestion is to take a whack at it, and post some code
with questions as you’re working through it.

good luck!

  • j

On Wed, Jun 29, 2011 at 10:37 AM, Mayank K.
[email protected]wrote:

  • If this goes well then would like to add year also along with the movie
    name.

Piracy is bad. Don’t do piracy. mmmkay?

As for your answer. look to the file class in core.

http://www.ruby-doc.org/core/classes/File.html
http://www.ruby-doc.org/core/classes/Dir.html

Also, shameless plug here, check out tryruby.org
I have a lesson in there that runs through using the basics of dir.
Granted, in my example I am using fakefs under the hood-- for security
purposes.

Couple of things which I want to achieve by developing this is to
understand
TDD(so yes I want to write tests for my application), Object Oriented
design. It would be great if somebody can mentor me also in my pet project.

You may want to start off with test unit. See if you can get a hold of a
copy of ruby in practice. I like how they teach BDD/TDD. Also the
defacto
BDD testing book is the RSpec Book.

Andrew McElroy

Please don’t steal movies.

Sam

On Wed, Jun 29, 2011 at 4:17 PM, Sam D. [email protected]
wrote:

Please don’t steal movies.

Sam

Lets just not even go here, please.

On Thu, Jun 30, 2011 at 06:17:55AM +0900, Sam D. wrote:

Please don’t steal movies.

  1. http://tinyurl.com/3mapksl

  2. What makes you think (s)he’s not just engaging in a little Fair Use?

  3. Isn’t this a little off-topic?

sigh

  1. Your humorous image is ridiculous in the context, but I hope it helps
    you sleep at night.

  2. Put that filename into your favourite search engine. If you already
    own it, you don’t need the Internet.

  3. That depends. Does the list have any rules about discussing (most
    likely) illegal activities?

The request could at least have used a fictional name, no? And then we
wouldn’t even be engaging in this discourse …

Sam

Nice links.

Sam, nobody’s interested. Piracy is the right thing to do.

On Jun 29, 2011, at 11:39 PM, Sam D. wrote:

  1. Your humorous image is ridiculous in the context, but I hope it helps you
    sleep at night.

http://i.imgur.com/GxzeV.jpg

Before this goes completely off the rails [sic], my points are;

*) Call the thread “A File Renamer”
*) Make up an example filename
*) Profit

Sam

On Wed, Jun 29, 2011 at 4:30 PM, Chad P. [email protected] wrote:

  1. Isn’t this a little off-topic?

I agree, lets leave the moral opinions out of it, this is a topic about
how
to rename files and develop using certain methodologies.

(btw, the pig pic made me giggle)

On Wed, Jun 29, 2011 at 5:35 PM, Sam D. [email protected]
wrote:

Before this goes completely off the rails [sic], my points are;

*) Call the thread “A File Renamer”
*) Make up an example filename
*) Profit

or this thread could just end because I answered it in the first email.
file.rename is the method he is looking for.

I linked to the file and the dir class documentation.

Andrew McElroy

I had to do something not completely dissimilar to this for a set of
files that were named with the author and date along with a series of
numbers such as 1.1.2.1.a etc. which needed extracting and changing to
titlecase.
Titlecase, gsub and regular expression parsing should do what you need
to determine the new filename.

True enough. Add;

http://www.ruby-doc.org/core/classes/String.html
http://www.ruby-doc.org/core/classes/String.html#M001193
http://www.ruby-doc.org/core/classes/String.html#M001161

And maybe even;

http://www.ruby-doc.org/core-1.9/classes/Pathname.html

Sam

On Thu, Jun 30, 2011 at 07:35:03AM +0900, Sam D. wrote:

Before this goes completely off the rails [sic], my points are;

No, wait – this could be instructive for later threads:

*) Call the thread “A File Renamer”

. . . or you could have pretended that’s what it’s called, and none of
this would have happened.

*) Make up an example filename

. . . or you could consider that the person in question might have used
the same software to create a copy for personal use as whoever it was
that posted an illegal copy on the Internet, and not jump to
conclusions,
thus potentially sparking an off-topic flamewar.

*) Profit

. . . or you could have contacted the person personally to tell
him/her
your opinion of “stealing” (which isn’t even the correct term) rather
than subject the rest of us to your self-righteousness.

I implore anyone else who considers taking the same approach as Sam
Duncan to consider my list of alternatives if any of you get the urge in
the future.

With that, I’m finished. Feel free to offer more declarations of moral
turpitude from on high if you like, Sam.

Maybe I’m thinking a bit amateurishly (only Rubying for a couple weeks
now),
but wouldn’t a regexp \w+ command for each filename suffice? Just return
everything before the . in the filename (guess you could avoid digits
first)
and rewrite the file name with the return + ’ '.

Guess you could add a raise exception if a movie was found pirated that
changes your username to ‘THIEF’

Really didn’t want to get into this, especially since it seems like
everyone
is done…

On Wednesday, June 29, 2011 04:39:32 PM Sam D. wrote:

sigh

  1. Your humorous image is ridiculous in the context, but I hope it helps
    you sleep at night.

Making a distinction between copyright infringement, piracy, and theft
does
not mean you condone either, or participate in either.

As the image says, theft removes the original.
Copyright infringement just makes a copy.

And for what it’s worth, regardless of what the humorous image says,
copyright
infringement isn’t piracy. Piracy is armed robbery on the high seas.

I’m not arguing that any of these things are OK, but I really wish
people
would keep some perspective.

I do agree with this, though:

  1. That depends. Does the list have any rules about discussing (most
    likely) illegal activities?

It’s not the legality that bothers me so much as the ethics, but either
are
worth at least mentioning in situations like this. Another place this is
done
is with homework questions – someone will point out that something
looks like
a homework question. I don’t always notice something wrong with the
question
itself, so I’m glad when people point it out, because I don’t want to
help
with homework questions.

Maybe other people feel the same way about “stealing” movies – you
might not
have noticed from the filename itself, but now that someone mentioned
it, you
don’t want to help with that.

But I don’t know. It’s a slippery slope.
We wouldn’t want ruby-talk to become morality-talk.

FWIW, I agree that this should be about ruby, not so much about morality
or ethics. :slight_smile:
Sent from my BlackBerry device on the Rogers Wireless Network

On Thu, Jun 30, 2011 at 9:46 AM, David M. [email protected]
wrote:

And for what it’s worth, regardless of what the humorous image says,
copyright
infringement isn’t piracy. Piracy is armed robbery on the high seas.

lol

Another place this is done
is with homework questions – someone will point out that something looks
like
a homework question. I don’t always notice something wrong with the
question
itself, so I’m glad when people point it out, because I don’t want to help
with homework questions.

I’m ambivalent about these cases.

I tend to think “the student knows better than I do what they need, I’ll
just give them all the tools and let them choose for themselves so as to
get
maximum benefit” but lately I wonder if people simply can’t make good
decisions, even if they want to. In that case, maybe having the answer
so
available causes them to choose the easy approach of just taking the
answer
rather than the best approach of taking the piece of information they
need
to be able to solve the problem.

Another place you see this is with troll feeding, people who mean well
and
know what they need to do, but just can’t bring themselves to do it.
Same
thing, I think. In that case, I decided, that instead of trusting people
to
learn enough to stop feeding the trolls, its best to just remove the
trolls.
And similarly, instead of trusting people to not just copy a solution
when
its not what they need, it may be best to just not provide the solution.

IDK, like I said, ambivalent.

On Fri, Jul 1, 2011 at 1:42 AM, David M. [email protected]
wrote:

I actually have some ethical issues with this. If you’re having this much
trouble with this sort of problem, you either need to learn fast, or you
need
to not pass the course. Maybe giving some people all the answers will help
them learn fast, but it also might help them pass a course they shouldn’t.

I honestly perceive this as “If someone needs help, that is evidence
that
they don’t deserve help.”

It’s also kind of doing their work for them.

Assuming the person is responsible, they are in a better place to decide
if
that is what they need than we are.

Also, if the course is at all decent, they have all sorts of other
resources
available to them. If they’re asking us and not their teacher (or TA), then
there’s probably a reason for that, and it probably has to do with
cheating.

This is why learning is so hard. No one will help you, everyone thinks
you
should suffer for knowledge.