« Partial Solar Eclipse | Main | Home sweet, home... »

Bash rename

This is one more for myself than anyone else as I keep forgetting how todo it.... but if anyone is interested. I normally don't use bash - I'm not entirely sure why I don't (if you don't know what bash is, then I wouldn't worry - its the Bourne Again Shell and is based on the Bourne shell, sh, the original command interpreter). Anyway, this is a very simple thing todo.. but every time I come todo it I have to look it up, so I'm going to just look it up here...

Just to add some text at the front:

for i in *; do mv "$i" "photo${i}.jpg" ; done

To remove some text in the string:

for i in *.jpg; do mv "$i" "${i/Yourself}" ; done

and to rename as a numeric string... my most common task...

number=0
for i in *.jpg; do mv "$i" "$number" ; (( number += 1 )); done

TrackBack

TrackBack URL for this entry:
http://www.krioma.net/cgi-bin/mt_new/mt-tb.cgi/320

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on August 6, 2008 10:22 PM.

The previous post in this blog was Partial Solar Eclipse.

The next post in this blog is Home sweet, home....

Many more can be found on the main index page or by looking through the archives.

Get Firefox! Valid XHTML 1.0! Valid CSS! RSS Feed BlogUniverse - listed Powered by Apache Creative Commons License ringsofsaturnrock's Most Interesting Photos on Flickriver

Powered by
Movable Type 3.33