substitute '%s' in string "%s_%s%s" with: file_root, next(count) and file_ext, join the dir_name and previous string into a valid file path, substitute it for name.
name = os . path . join ( dir_name , "%s_%s%s" % ( file_root , next ( count ) , file_ext ) )