import os

import beets.util
from beets import config
from beets.plugins import BeetsPlugin

class CopyArtifactsPlugin(BeetsPlugin):
    def __init__(self):
        super(CopyArtifactsPlugin, self).__init__()

        self.config.add({
            'extensions': '.*',
            'print_ignored': 'no'
        })

        self.extensions = self.config['extensions'].get().split()
        self.print_ignored = self.config['print_ignored'].get()

        self.register_listener('import_task_files', self.add_artifacts)

    def add_artifacts(self, task, session):
        # there has to be a better way of doing this
        dest_path = set(os.path.dirname(i.path) for i in task.imported_items())
        dest_path = list(dest_path)[0]

        source_files = []
        ignored_files = []
        for filename in os.listdir(task.paths[0]):
            source_file = os.path.join(task.paths[0], filename)
            if source_file in task.old_paths:
                continue

            if os.path.isfile(source_file):
                ext = os.path.splitext(filename)[1]

                if '.*' in self.extensions or ext in self.extensions:
                    source_files.append(source_file)
                else:
                    ignored_files.append(source_file)

        if source_files:
            if config['import']['move']:
                print 'Moving artifacts:'
            elif config['import']['copy']:
                print 'Copying artifacts:'
                
            for source_file in source_files:
                filename = os.path.basename(source_file)
                dest_file = beets.util.unique_path(os.path.join(dest_path, filename))

                print '   ', os.path.basename(dest_file)
                
                if config['import']['move']:
                    beets.util.move(source_file, dest_file)
                elif config['import']['copy']:
                    beets.util.copy(source_file, dest_file)

        if self.print_ignored and ignored_files:
            print 'Ignored files:'
            for f in ignored_files:
                print '   ', os.path.basename(f)


@@ -26,33 +26,8 @@
 til%0A
-from beets import config%0A
 from
@@ -544,337 +544,949 @@
   # 
-there has to be a better way of doing this%0A        dest_path = set(os.path.dirname(i.path) for i in task.imported_items())%0A        dest_path = list(dest_path)%5B0%5D%0A%0A        source_files = %5B%5D%0A        ignored_files = %5B%5D%0A        for filename in os.listdir(task.paths%5B0%5D):%0A            source_file = os.path.join(task.paths%5B0%5D, filename
+Get the import move and copy config options to determine if files should be copied or moved%0A        move = beets.config%5B'import'%5D%5B'move'%5D.get()%0A        copy = beets.config%5B'import'%5D%5B'copy'%5D.get()%0A%0A        # Don't do anything if not moving or copying%0A        if not (move or copy):%0A            return None%0A        %0A        # Get the destintation path by taking the first unique path of the files aready imported %0A        # there has to be a better way of doing this%0A        dest_path = set(os.path.dirname(i.path) for i in task.imported_items())%0A        dest_path = list(dest_path)%5B0%5D%0A%0A        source_files = %5B%5D%0A        ignored_files = %5B%5D%0A%0A        # Loop over the files in the directory being imported%0A        for filename in os.listdir(task.paths%5B0%5D):%0A%0A            # Get the filename including absolute path%0A            source_file = os.path.join(task.paths%5B0%5D, filename)%0A%0A            # Skip this file if it is a music file (already imported
 )%0A  
@@ -1555,16 +1555,71 @@
 ntinue%0A%0A
+            # Ensure this file is regular and existing%0A
         
@@ -1653,16 +1653,58 @@
 e_file):
+%0A%0A                # Get the file extension
 %0A       
@@ -1749,16 +1749,103 @@
 me)%5B1%5D%0A%0A
+                # Add the file to the source or ignore list depending on config option%0A
         
@@ -2048,64 +2048,133 @@
     
-if
+# Copy or move (depending on config option) any
  source
-_
+ 
 files
-:%0A            if config%5B'import'%5D%5B'
+ to destination path%0A        if source_files:%0A            if 
 move
-'%5D
 :%0A  
@@ -2231,35 +2231,10 @@
   el
-if config%5B'import'%5D%5B'copy'%5D
+se
 :%0A  
@@ -2577,32 +2577,12 @@
  if 
-config%5B'import'%5D%5B'
 move
-'%5D
 :%0A  
@@ -2661,35 +2661,10 @@
   el
-if config%5B'import'%5D%5B'copy'%5D
+se
 :%0A  
@@ -2714,32 +2714,97 @@
 le, dest_file)%0A%0A
+        # Print out any ignored files depending on config option%0A
         if self.

Add comments and check if not moving or copying