hey all..if I have a 5 files in PDF named PDF1, PDF2, PDF3, PDF4, PDF5
I want to create a program that renames them to
project 1, project 2, project 3, project 4, project 5

import os,sys

namelist=['jon',
'leon',
'david',
'nombre',]
for filename in os.listdir("C://YOUR/PATH/HERE/"):

os.rename(filename, namelist.pop())

print "succesfuly renamed"

[A friend sent me this, how can I use this to rename files?]
ty

This will do it,run script in same folder as pdf1,pdf2...
Output will be project 1, project 2...
Be aware that this will rename all pdfs in folder that you run script in.

import os
import glob

for numb, name in enumerate(glob.glob('*pdf'), 1):
    #print numb, name #test
    os.rename(name, 'project %s.pdf' % numb)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.