Here's the scenario:
I have a folder WITH SPACES in its name. We'll call this folder "D:\Source Folder With Spaces." This folder also has many different sub-folders. Within these subfolders, I have files of different file extensions, let's say just .dat and .exe files. I am trying to write a batch file that will search through "Source Folder With Spaces" and ALL of it's sub-folders for .exe files and move OR del (I'd be happy with either outcome) ONLY .exe files (regardless of file name) to another folder location. Also, some of the files that need to be moved/deleted may even contain spaces in their names. Now, if "D:\Source Folder With Spaces" were only named "D:\Source," I would very easily be able to tackle this task with the following code:
Code: Select all
FOR /R D:\Source %%f in (*.mp3) DO MOVE %%f "D:\Destination
As soon as I add a space to the folder name, though, like so:
Code: Select all
FOR /R "D:\Source Folder With Spaces" %%f in (*.mp3) DO MOVE %%f "D:\Destination Folder That Might Also Have Spaces In Name"
It apparently sees these spaces as such a predicament, such a burden, that the batch file does nothing more when opened than opening and immediately closing with no action whatsoever taken in between. I've done exhaustive amounts of research to find virtually no answer to this confounded puzzle.
NOTE: PLEASE do not respond by simply saying, "Just rename the folders so they don't contain spaces in the names," because if that were an okay solution for me, well, then I wouldn't be here posting.
OS Info: I'm running Windows 7 64-bit