diff --git a/beets/library.py b/beets/library.py index 5a22e4ed8..f832cc465 100644 --- a/beets/library.py +++ b/beets/library.py @@ -539,28 +539,17 @@ class Library(object): #### main interface #### - def add(self, path, clobber=False): + def add(self, path): """Add a file to the library or recursively search a directory and add all its contents.""" - if os.path.isdir(path): # directory - # recurse into contents - for ent in os.listdir(path): - self.add(path + os.sep + ent, clobber) - - elif os.path.isfile(path): # normal file - #fixme avoid clobbering/duplicates! - # add _if_ it's legible (otherwise ignore but say so) - try: - Item.from_path(_normpath(path), self) - except FileTypeError: - _log(path + ' of unknown type, skipping') - - elif not os.path.exists(path): # no file - raise IOError('file not found: ' + path) - - else: # something else: special file? - _log(path + ' special file, skipping') + for root, dirs, files in os.walk(path): + for filebase in files: + filepath = os.join(root, filebase) + try: + Item.from_path(_normpath(filepath), self) + except FileTypeError: + _log(filepath + ' of unknown type, skipping') def get(self, query=None): """Returns a ResultIterator to the items matching query, which may be diff --git a/bts.py b/bts.py index 9b5345e30..545d6223a 100755 --- a/bts.py +++ b/bts.py @@ -14,6 +14,10 @@ def ls(lib, criteria): for item in lib.get(q): print item.artist + ' - ' + item.album + ' - ' + item.title +def imp(lib, paths): + for path in paths: + pass + if __name__ == "__main__": # parse options usage = """usage: %prog [options] command @@ -38,11 +42,12 @@ command is one of: add, remove, update, write, list, help""" # choose which command to invoke avail_commands = [ (add, ['add']), + (imp, ['import', 'im', 'imp']), #(remove, ['remove', 'rm']), #(update, ['update', 'up']), #(write, ['write', 'wr', 'w']), (ls, ['list', 'ls']), - (help, ['help', 'h']) + (help, ['help', 'h']), ] for test_command in avail_commands: if cmd in test_command[1]: