As part of some image analysis work I’ve been doing, I need to sort a large number of images quickly. I did a previous bash script post on the same topic recently (here).
The images were not as well curated as I hope for (varying numbers of photos from different angles of the same object and place-holder images were not machine readable), so I had to take a more manual approach.
Since Windows is my main OS for work, here is a bat script that will copy files into a new folder, based on the file name of the first file in a selection of files, by dragging and dropping.
I created several other versions of the script until I had the one I was happy with, however, this code may be of use still so I’m posting this for legacy purposes.
Bat script (.zip): _file_mover.zip
To run:
Drag and drop files onto bat script – will create a folder called “./moved/folder_”{Filename of first file in selection}”
REM _file_mover.bat REM Usage: Drag and drop files onto bat script - will create a folder called "folder_"{Filename of first file in selection} REM Gordon Wellman - 2017 @echo off setlocal enabledelayedexpansion set argCount=0 for %%x in (%*) do ( set /A argCount+=1 set "argVec[!argCount!]=%%~x" ) echo Number of processed arguments: %argCount% For %%A in (!argVec[1]!) do ( Set Folder=%%~dpA Set Name=%%~nxA ) echo Folder is: %Folder% echo Name is: %Name% set FolderName=folder_%Name% REM You can change the filepath below if you - Remember to update the one below as well mkdir "./moved/%FolderName%" for /L %%i in (1,1,%argCount%) do ( echo %%i- "!argVec[%%i]!" REM You can change the filepath below if you xcopy "!argVec[%%i]!" "./moved/%FolderName%" Rem Check result code and if it was successful (0), delete the source. if errorlevel 0 ( echo Copy completed successfully REM Maybe for the first run, REM out the line below to stop it from deleting images until you have checked that the images are copied correctly del /Q "!argVec[%%i]!" ) )