def filename_task(task, session):
 items = (task.items if task.is_album else [task.item])
 missing_titles = sum((bad_title(i.title) for i in items))
 if missing_titles:
  names = {}
  for item in items:
   path = displayable_path(item.path)
   (name, _) = os.path.splitext(os.path.basename(path))
   names[item] = name
  for pattern in PATTERNS:
   d = all_matches(names, pattern)
   if d:
    apply_matches(d)

def filename_task ( task , session ) : items = ( task . items if task . is_album else [ task . item ] ) missing_titles = sum ( ( bad_title ( i . title ) for i in items ) ) if missing_titles : names = { } for item in items : path = displayable_path ( item . path ) ( name , _ ) = os . path . splitext ( os . path . basename ( path ) ) names [ item ] = name for pattern in PATTERNS : d = all_matches ( names , pattern ) if d : apply_matches ( d )
examine each item in the task to see if we can extract a title from the filename .