Add a folder scan images there
422268
def add_folder(self, folder):
        
        if folder in self.folders:
            return

        self.folders.add(folder)
        
        for subfolder, junk, filenames in os.walk(folder):
            for filename in filenames:
                name, ext = os.path.splitext(filename)
                if ext in self.exts:
                    self.images.append(
                        os.path.join(subfolder, filename))
1086269
async function scandir(dir, recursive=true, absolutePaths=false){
    // get absolute path
    const absPath = _path.resolve(dir);

    // stats command executable ? dir/file exists
    const stats = await _fs.stat(absPath);

    // check if its a directory
    if (!stats.isDirectory()){
        throw new Error('Requested directory <' + absPath  + '> is not of type directory');
    }

    // use absolute paths ?
    if (absolutePaths){
        dir = absPath;
    }

    // stack of directories to scan
    const dirstack = [dir];

    // list of files
    const files = [];

    // list of directories
    const directories = [];

    // iterative scan files
    while (dirstack.length > 0){
        // get current directory
        const currentDir = dirstack.pop();

        // get current dir items
        const itemNames = await _fs.readdir(currentDir);

        // get item stats (parallel)
        const itemStats = await Promise.all(itemNames.map((item) => _fs.stat(_path.join(currentDir, item))));

        // process item stats
        for (let i=0;i<itemNames.length;i++){
            // prepend current path
            const currentItem = _path.join(currentDir, itemNames[i]);

            // directory ? push to stack and directory list
            if (itemStats[i].isDirectory()){
                // recursive mode ?
                if (recursive){
                    dirstack.push(currentItem);
                }
                
                // store dir entry
                directories.push(currentItem);

            // file, socket, symlink, device..
            }else{
                // push to filelist
                files.push(currentItem);
            }
        }
    }

    // return file and directory list
    return [files, directories];
}
804490
def organize_dir(orig_dir):
    ''''''

    tags = [
        (0x10,0x20),    # Subj ID
        (0x8,0x21),     # Date
        (0x8,0x31),     # Time
        (0x8,0x103e)    # Descr
    ]
    orig_dir = orig_dir.rstrip('/')
    files = scan_dir(orig_dir,tags=tags,md5_hash=True)
    dups = find_dups(files)
    for dup in dups:
        nl.notify('Found duplicates of %s...' % dup[0])
        for each_dup in dup[1:]:
            nl.notify('\tdeleting %s' % each_dup)
            try:
                os.remove(each_dup)
            except IOError:
                nl.notify('\t[failed]')
            del(files[each_dup])

    clustered = cluster_files(files)
    output_dir = '%s-sorted' % orig_dir
    for key in clustered:
        if (0x8,0x31) in clustered[key]['info']:
            clustered[key]['info'][(0x8,0x31)] = str(int(float(clustered[key]['info'][(0x8,0x31)])))
        for t in tags:
            if t not in clustered[key]['info']:
                clustered[key]['info'][t] = '_'
        run_name = '-'.join([scrub_fname(str(clustered[key]['info'][x])) for x in tags])+'-%d_images' %len(clustered[key]['files'])
        run_dir = os.path.join(output_dir,run_name)
        nl.notify('Moving files into %s' % run_dir)
        try:
            if not os.path.exists(run_dir):
                os.makedirs(run_dir)
        except IOError:
            nl.notify('Error: failed to create directory %s' % run_dir)
        else:
            for f in clustered[key]['files']:
                try:
                    dset_fname = os.path.split(f)[1]
                    if dset_fname[0]=='.':
                        dset_fname = '_' + dset_fname[1:]
                    os.rename(f,os.path.join(run_dir,dset_fname))
                except (IOError, OSError):
                    pass
    for r,ds,fs in os.walk(output_dir,topdown=False):
        for d in ds:
            dname = os.path.join(r,d)
            if len(os.listdir(dname))==0:
                os.remove(dname)
636834
def _add_image(collection, image):
    '''
    
    '''
    image_prep = {
            'id': image.id,
            'name': image.name,
            'created_at': image.created_at,
            'file': image.file,
            'min_disk': image.min_disk,
            'min_ram': image.min_ram,
            'owner': image.owner,
            'protected': image.protected,
            'status': image.status,
            'tags': image.tags,
            'updated_at': image.updated_at,
            'visibility': image.visibility,
        }
    # Those cause AttributeErrors in Icehouse' glanceclient
    for attr in ['container_format', 'disk_format', 'size']:
        if attr in image:
            image_prep[attr] = image[attr]
    if type(collection) is dict:
        collection[image.name] = image_prep
    elif type(collection) is list:
        collection.append(image_prep)
    else:
        msg = '"collection" is {0}'.format(type(collection)) +\
            'instead of dict or list.'
        log.error(msg)
        raise TypeError(msg)
    return collection
508075
function addImageToCells(imageId, range) {
    const model = {
      type: 'image',
      imageId,
      range,
    };
    this._media.push(new Image(this, model));
  }
1284962
public function scanSourceFolders() {
        $this->addons = [];
        foreach ($this->sources as $sourceDir) {
            $this->scanSource($sourceDir);
        }
    }
110716
function addMaping(folder) {
	Object.defineProperties(folder, {
		// Return all enumerable properties
		_subfiles: {
			get: function () {
                return filter(folder, {type: ['file','directory']}, 'keys');
            }
		},
		// Return properties with _type === 'file'
		_files: {
			get: function () {
                return filter(folder, {type: 'file'}, 'keys');
			}
		},
		// Return properties with _type === 'directory'
		_folders: {
			get: function () {
                return filter(folder, {type: 'directory'}, 'keys');
			}
		},
        __filter: {
            value: function (opts, returnArray) {
                if(!opts.recursive) {
                    return filter(folder, opts, returnArray);
                }
                opts.recursive = false;
                if(!returnArray) {
                    return filter(folder, opts, returnArray);
                }
                return filterRecursive(folder, opts, returnArray);
            }
        },
        __clear: {
            value: function () {
                folder._subfiles.forEach(function (key) {
                    delete folder[key];
                });
            }
        },
		// Function for starting mapping from current folder with opts
		__map: {
			value: function (opts, callback) {
				if (typeof opts === 'function') {
					callback = opts;
					opts = {};
				}

				folder.__list(function (err, list) {
					if (err) {
						callback(err);
						return;
					}
					mapObjects(folder, list, function (err, map) {
						if (err) {
							callback(err);
							return;
						}
						var folders = transfer(folder, map, opts);
						var count = folders.length;

						if (!opts.recursive || count === 0) {
                            if(!opts.extend) {
                                callback(null, folder);
                                return;
                            }

                            extendComponents(folder, opts, callback);
							return;
						}

						var sent = false;
						folders.forEach(function (f) {
							f.__map(opts, function (err, fMap) {
								if (err) {
									if (!sent) {
										callback(err);
										sent = true;
									}
									return;
								}
                                if (!opts.simple) {
                                    transfer(folder, fMap, opts);
                                }
								if (--count === 0) {
                                    if(!opts.extend) {
                                        callback(null, folder);
                                        return;
                                    }
                                    extendComponents(folder, opts, callback);
								}
							});
						});
					});
				});
			}
		},
        __reMap: {
            value: function (callback) {
                folder.__clear();
                folder.__map(callback);
            }
        },
        __watchMap: {
            value: function (persistent, callback) {
                if(typeof persistent === 'function') {
                    callback = persistent;
                    persistent = false;
                }
                folder.__watchList(persistent, function (err, list) {
                    if(err) {
                        callback(err);
                        return;
                    }
                    folder.__reMap(callback);
                });
            }
        },
        __extend: {
            value: function (map) {
                return utils.extend(folder, map, true);
            }
        }
	});
}
1240691
public List<File> scan(Resource resource) {
        Scanner scanner = buildContext.newScanner(new File(resource.getDirectory()), true);
        setupScanner(scanner, resource);
        scanner.scan();
        List<File> files = new ArrayList<File>();
        for (String file : scanner.getIncludedFiles()) {
            files.add(new File(resource.getDirectory(), file));
        }
        return files;
    }
584355
private function _scan(&$fromDir, &$toDir, &$files, &$dirs)
    {
        /* mappers should be generic, so we get the mappers here and
        pass them on to builMap. This method is not redundan like it seems */
        $mapper = $this->getMapper();

        $this->buildMap($fromDir, $toDir, $files, $mapper, $this->fileCopyMap);

        if ($this->includeEmpty) {
            $this->buildMap($fromDir, $toDir, $dirs, $mapper, $this->dirCopyMap);
        }
    }
235346
protected void scanDir(File srcDir, File destDir, String[] files) {
        GlobPatternMapper m = new GlobPatternMapper();
        SourceFileScanner sfs = new SourceFileScanner(this);
        File[] newFiles;
        for (String extension : getScriptExtensions()) {
            m.setFrom("*." + extension);
            m.setTo("*.class");
            newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
            addToCompileList(newFiles);
        }

        if (jointCompilation) {
            m.setFrom("*.java");
            m.setTo("*.class");
            newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
            addToCompileList(newFiles);
        }
    }
1245333
private function scanModuleFiles($basedir, &$folders)
    {
        if (is_dir($basedir) && ($h = opendir($basedir))) {
            while (($filename = readdir($h))) {
                $phpfile = $basedir . DIRECTORY_SEPARATOR . $filename;
                if (preg_match('/^init[_|-](.+)\.php$/', $filename) && file_exists($phpfile) && filesize($phpfile) > 0) {
                    $folders[] = $phpfile;
                }
            }
            closedir($h);
        }
    }
362644
def add_image(self, batch_id, image_id, image_properties=None):
    """"""
    if batch_id not in self._data:
      raise KeyError('Batch with ID "{0}" does not exist'.format(batch_id))
    if image_properties is None:
      image_properties = {}
    if not isinstance(image_properties, dict):
      raise ValueError('image_properties has to be dict, however it was: '
                       + str(type(image_properties)))
    self._data[batch_id]['images'][image_id] = image_properties.copy()
315440
private void addGalleryEntries(CmsGalleryTreeItem parent, List<CmsGalleryFolderEntry> galleries) {

        for (CmsGalleryFolderEntry galleryFolder : galleries) {
            CmsGalleryTreeItem folderItem = createGalleryFolderItem(galleryFolder);
            parent.addChild(folderItem);
            m_galleryTreeItems.put(galleryFolder.getStructureId(), folderItem);
            addGalleryEntries(folderItem, galleryFolder.getSubGalleries());
        }
    }
1024263
def add(image_path, file_name=None):
    """"""
    if file_name is not None:
        dst_path = os.path.join(IMG_DIR, str(Path(file_name).stem + Path(image_path).suffix))
    else:
        dst_path = IMG_DIR

    if os.path.isfile(image_path):
        shutil.copy2(image_path, dst_path)
126585
def main(input_file, output, format):
    """"""

    try:
        process_image(input_file, subfolder=output, ext=format)
    except Exception as e:
        sys.exit(e)
944548
public function scan()
    {
        $files = $this->finder->create()->in($this->getBasePath())->name('theme.json');
        foreach ($files as $file) {
            $this->register($file);
        }
    }
85849
private void loadFolder(File folder) {
        m_logger.info("Scanning for files in folder: {}", folder.getAbsolutePath());
        File[] files = folder.listFiles();
        if (files == null || files.length == 0) {
            m_logger.error("No files found in folder: {}", folder.getAbsolutePath());
            return;
        }
        
        for (File file : files) {
            String fileName = file.getName().toLowerCase();
            if (!fileName.endsWith(".csv") && !fileName.endsWith(".zip")) {
                continue;
            }
            TableDefinition tableDef = determineTableFromFileName(file.getName());
            if (tableDef == null) {
                m_logger.error("Ignoring file; unknown corresponding table: {}", file.getName());
                continue;
            }
            try {
                if (fileName.endsWith(".csv")) {
                    loadCSVFile(tableDef, file);
                } else  {
                    loadZIPFile(tableDef, file);
                }
            } catch (IOException ex) {
                m_logger.error("I/O error scanning file '{}': {}", file.getName(), ex);
            }
        }
    }