Whoops... Forgot one more thing. You should add the /I operator to the IF command to make sure it does case-insensitive string comparisons, just to be safe. And quotes around the comparison strings make things a bit clearer. So a working command should be very similar to this: FOR /R c:\temp %f IN (*) DO IF /I NOT "%~xf"==".gpg" gpg --encrypt %f Regards, Ryan