Okay, I give up. I just changed it back to what is was originally ("%%a" in that first line), and now the batch file works perfectly again. I'm annoyed.
Oh, and I found out ('dir F:\ /ad /b /o-d') should have read ('dir F:\ /ad /b /o-n') because it was sorting by creation date, not the actual...