from string import lower, find #rm .lck files objs = context.objectIds() #all the object ids in current folder for id in objs: #trash anything that ends with .LCK if lower(id[-4:])=='.lck': print 'deleteing DW lock, ' + id context.manage_delObjects(id) #anything that ends with .htm or html if lower(id[-4:]) in ('.htm', 'html'): no_extension = id[:find(id, '.htm')] if no_extension in objs: print 'deleteing file w/o extension, ' + no_extension context.manage_delObjects(no_extension) print 'made copy of, ' + id context.manage_pasteObjects(context.manage_copyObjects(id)) print 'renaming '+id+' to '+no_extension context.manage_renameObjects((id,), (no_extension,)) for id in context.objectIds(): s, l = 'copy_of_', len('copy_of_') if id[:l]==s: print 'renaming '+id+' to '+id[l:] context.manage_renameObjects((id,), (id[l:],)) return printed