Decorator to split files into manageable chunks as not to exceed the windows cmd limit

    :param func: Function to call for each chunk
    :type func: :py:class:Function

def split_ls(func):
    """Decorator to split files into manageable chunks as not to exceed the windows cmd limit

    :param func: Function to call for each chunk
    :type func: :py:class:Function
    """
    @wraps(func)
    def wrapper(self, files, silent=True, exclude_deleted=False):
        if not isinstance(files, (tuple, list)):
            files = [files]

        counter = 0
        index = 0
        results = []

        while files:
            if index >= len(files):
                results += func(self, files, silent, exclude_deleted)
                break

            length = len(str(files[index]))
            if length + counter > CHAR_LIMIT:
                # -- at our limit
                runfiles = files[:index]
                files = files[index:]
                counter = 0
                index = 0
                results += func(self, runfiles, silent, exclude_deleted)
                runfiles = None
                del runfiles
            else:
                index += 1
                counter += length

        return results

    return wrapper