Sample Windows batch script to copy JPGs, RW2s, and MP4s from SD Card to local computer.

I came across a common problem among photographers: lack of storage space. With RAW images at 20MB/file, my hard drive is filling up quickly.

I came up with a plan to filter images directly on the SD Card before I copy to the local machine. Since I save both JPG and RAW images on the card, I could filter the JPGs that I liked (delete the JPGs that I don’t) and then copy the remaining JPGs and respective RAW images to my local machine. Unfortunately, this posed a problem of having to manually select the JPG and respective RAW images. It seemed like an enormous waste of my time so I did not even attempt it manually.

I knew I could solve this programatically. I wrote a Windows batch script to check the current directory for existing JPG images, then copy both the JPG and corresponding RAW images to the destination folder.

Batch scripting took me back to the early 90’s! It’s been a while! After some research, I was able to put together the script below. You will have to update it with your destination directory.

 REM For each JPG, copy both the JPG and RAW image to the target folder
set target="F:\Media\2019."
FOR %%y in (*.JPG) DO CALL :loopbody %%y
copy *.mp4 %target%
set filename=%1
set jpg=%filename:~0,-4%.JPG
set rw2=%filename:~0,-4%.RW2
copy %jpg% %target%
copy %rw2% %target%
0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x