[ start | index | login ]
start > rename.py

rename.py

Created by admin. Last edited by admin, one year and 184 days ago. Viewed 601 times. #4
[diff] [history] [edit] [rdf]
labels
attachments
This is a simple python script which renames all the files in a folder to a new name which consists of a prefix and an incrementing index. This can be really useful in renaming files such as digital pictures, etc which can sometimes overlap in their naming.
import os

# this is the count at which the new filenames will start index = 117 # this is an optional prefix to each filename before the index above prefix = 'condo ' # this is the folder in which to rename all the files pixDir = '~/work/pix/temp'

# iterate over the pix and rename them os.chdir( pixDir) for f in os.listdir( pixDir): newName = '%s%s.jpg' % ( prefix, index) print f, '->', newName os.rename( f, newName) index = index + 1

no comments | post comment

Main Menu

  1. Daily Stuff
  2. Hacking
  3. Fun Stuff
  4. Contact Me
  5. >>Nimsoft.biz
  6. >>Seattle Traffic on your cell
December 2008
SunMonTueWedThuFriSat
123456
78910111213
14151617181920
21222324252627
28293031

>>Java RSS Feeds
>>PopURLS

XHTML 1.0 validated
CSS validated
RSS 2.0 validated
RSS Feed

Powered by SnipSnap 1.0b2-uttoxeter

Describe here what your SnipSnap is about!

Configure this box!

  1. Login in
  2. Click here: snipsnap-portlet-2
  3. Edit this box
snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt