Q:

How to choose available drives except pendrive for backup operation?

I made this script for my home computers to easy backup all my collection of photos and videos to one external hard drive.
SET BackUpDir=%~d0\BackUpDir

for %%d in (C:\ D:\) do (
    if exist %%d (
    robocopy %%d %BackUpDir% *.jpg *.jpeg *.dng *.nef *.mp4 *.mov *.wmv *.avi *.3gp *.3g2 /MIN:20000 /MAX:2703622144 /s /W:15 /XD C:\$WINDOWS.~BT "C:\System Volume Information" C:\Windows "C:\Program Files" C:\Boot C:\MSOCache C:\Recovery "C:\Program Files (x86)" "C:\Documents and Settings" C:\ProgramData "C:\Users\All Users" C:\Users\Default "C:\Users\Default User" C:\Users\defaultuser0 C:\Users\Public )
)
exit 0

I have a few computers with different partition structures. One of them has only the drives C: and D:, but for example second one has five partitions. 
Now I have this line of code with looking for files only on two partitions:
for %%d in (C:\ D:\) do (

I don't want to edit script every time to add additional partitions which don't exist for example on first computer, but do exist on second computer. I want my script to find automatically all available partitions on the computer except external hard drive from which backup script is executed.
How to change the command line above to make this happen?
I want something like this:
for %%d in ("list of all partition" except "backup external hard drive") do (

A:

You already know how to get the drive you want to exclude, it's there in the first line, %~d0, since you're using it to set the directory you want to back up to.
In addition, you can use exist to find out which drives actually exist.
So the following script will process all drives that exists and that do not match the one where your script is running from:
@echo off
rem Expand following list as needed.
for %%d in (C D E F G H I J) do (
    if exist %%d:\. if not %%d:==%~d0 (
        echo Processing drive %%d
    )
)

When I run that from drive C: on my system, which has the C: drive, an empty D: DVD, and the E: SSD, I get:
Processing drive E

