Windows Batch Scripting

Recently I’ve become more and more interested in scripting languages and automation. At my day job, I can be responsible for preparing large amounts of data to send to our third-party vendors, drop-shippers, or wholesalers etc. I use a simple MySQL database to manage all the product data and that works very well, however, sometimes I need to prepare large sets of images that correspond to the product data.

Procuring these image files was troublesome, to say the least, and I really needed an automated way to query the images directory and copy the matching images to a new directory. After tinkering around with batch files in Windows I found a quick solution that works great for me.

The script below should be saved as a Window’s Batch (.bat) file and placed in the Copied_Images directory along with the image-list.csv. The image-list.csv is a list of image names that the script will loop through and search the main image directory for. When a match is found the file will be copied to the Copied_Images directory. This script is searching for exact matches (including file extensions), so please prepare your .csv file accordingly. TheDir is the main image directory where all the images are stored.

The script can obviously be used for any type of file and it also searches through all the sub-folders/directories within the main TheDir directory. This is just a quick fix and I look forward to expanding on this idea and building more of a tool around it in the future.

Leave a Reply