I'm trying to scan files in directorys for text inside, but whenever I come across a file that has the ' - Copy' added to the end of it from windows, the program will not read it. I've tried using quotes within the name being passed, but no dice.
FOR /R %%F in (*.CDP) do (
for /f "tokens=*" %%a in (%%~nxF) do (
I've been using this code and have no issues with the typical files Im seeing. however if its something like dummy_file - Copy, I will get an error from the program saying 'System cannot find the file dummy_file.' period included. If I use
FOR /R %%F in (*.CDP) do (
for /f "tokens=*" %%a in ("%%~nxF") do (
Then the second for loop gets skipped, and the program proceeds on. I thought this would made the loop take it as a string literal, but apparently the for loop has its own way of reading things.
Is it possible to accept files in this loop that have a - Copy in them? Will I be able to use dummy_file - Copy.cdp here?
"tokens=*"with"delims=".for /R %%F in (*.cdp) do ( something with "%%~nxF" )? The only benefit to your innerfor /fwould be if you intend to massage and tokenize the parts of each file name, or if you intended to process the contents of each file (in which case you should enclose"%%~nxF"in quotation marks and add theusebackqoption). I'm wondering if some other part of your code you haven't pasted is where the real problem lies. Are you trying toset "variable=%%~nxF"and neglecting to enable delayed expansion when you go to retrieve!variable!perhaps?usebackqoption before, it did the trick. I am processing the input within the other loop, which is why I have two. I do haveset enabledelayedexpansionand no problems came from it. Again, thanks for letting me knowusebackqis a thing.