6 Replies - 5639 Views - Last Post: 19 January 2012 - 09:31 AM Rate Topic: -----

#1 pnev  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 13-February 10

Bash Programming to batch rename

Posted 04 January 2012 - 01:57 AM

So I want to rename a bunch of files that I have. They all have a bunch of numbers in the middle of the file that I want to remove. I know that I can use a combination of for looping in bash with regular expressions to do this. However, I'm bad at bash. I've written little scripts before, but they take me much longer than they should. I've gone through some regex tutorials, and some bash tutorials, but neither say "this is how you get the files in pwd and process them" very clearly. I end up with whitespace issues and not being able to read stuff and all kinds of problems that I really don't like.

I want to get to a point where I can just boot up terminal (running mac OS X), spend a minute figuring out what the for loop should be and then just write and execute it. I'm at that point with many other programming languages, but for some reason bash eludes me.

Can anyone recommend a good tutorial for me to work my way through that will get me to the aforementioned level?

I've gone through a lot of this tutorial and most of this one as well as many hours googling, but I can't seem to find one that explains everything I need to know.

TLDR I need a good, practical bash tutorial for batch file processing.

Is This A Good Question/Topic? 0
  • +

Replies To: Bash Programming to batch rename

#2 pnev  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 13-February 10

Re: Bash Programming to batch rename

Posted 04 January 2012 - 09:17 PM

Anyone?
Was This Post Helpful? 0
  • +
  • -

#3 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1383
  • View blog
  • Posts: 3,514
  • Joined: 28-November 09

Re: Bash Programming to batch rename

Posted 11 January 2012 - 01:39 AM

mv can rename the files, and if you've really went into regex you'd have a far easier time figuring this out.

http://linux.die.net...de/chap_04.html
Was This Post Helpful? 1
  • +
  • -

#4 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5392
  • View blog
  • Posts: 27,387
  • Joined: 10-May 07

Re: Bash Programming to batch rename

Posted 11 January 2012 - 01:51 AM

View Postpnev, on 04 January 2012 - 11:17 PM, said:

Anyone?

Can you provide an example of file names before the rename & after?
Was This Post Helpful? 0
  • +
  • -

#5 pnev  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 13-February 10

Re: Bash Programming to batch rename

Posted 13 January 2012 - 03:58 PM

Thanks for the two responses, but the file renaming is just a side issue. I want to be able to program in bash better. I want to be able to batch process files using regex and for loops. Do either of you know any good bash or regex (or ideally a combination of both) that could get me to this level?
Was This Post Helpful? 0
  • +
  • -

#6 pnev  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 13-February 10

Re: Bash Programming to batch rename

Posted 13 January 2012 - 04:00 PM

Thanks for the two responses, but the file renaming is just a side issue. I want to be able to program in bash better. I want to be able to batch process files using regex and for loops. Do either of you know any good bash or regex (or ideally a combination of both) that could get me to this level?
Was This Post Helpful? 0
  • +
  • -

#7 Gorian  Icon User is offline

  • ninja DIC
  • member icon

Reputation: 120
  • View blog
  • Posts: 1,681
  • Joined: 28-June 08

Re: Bash Programming to batch rename

Posted 19 January 2012 - 09:31 AM

A good place to start: http://www.dreaminco...bash-resources/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1