Batch file recursion not working with LFNS

August 27, 2010 at 14:27:11
Specs: Windows XP, amd/1024
I am trying to make a batch file to run all specified files and subfolder of a dir and make a command for each file it finds, this is my code:

set str=%2
set st123=%str:~1,-1%
for /f %%F in ('dir "%st123%\%1" /s /b') do (
start /w notepad %%F
)

Won't work with LFNs, I have searched everywhere and can't find this. I invoke with:

bfile *.txt "C:\Documents and Settings\user\Desktop\1"

How do I get it to work with LFNs?


See More: Batch file recursion not working with LFNS

Report •


#1
August 28, 2010 at 06:50:22
Or is there another way to this using something other than the for statement?

Report •

#2
August 28, 2010 at 22:41:57
AFAIK your problem has nothing to do with LFN. You haven't changed delims so a space, which is one of the defaults, is still in vogue and the first space encountered is after Documents so the system is looking for a file in Documents\*.txt. Try this:

@echo off
cls
setlocal 

set str=%2
set st123=%str:~1,-1%

for /f "tokens=*" %%F in ('dir "%st123%\%1" /s /b') do (
    start /w notepad %%F
)


Report •

#3
August 30, 2010 at 06:29:45
Sweet! Just what I was looking for, thanks for the assistance.

Report •

Related Solutions

#4
August 30, 2010 at 15:27:03
You're welcome & thanks for coming back with news of your success.


Report •

#5
August 31, 2010 at 06:53:35
Another question, using the same code how do I remove the extension from the end of the %%F?? I have tried a couple of ways and it is still not working.

Report •

#6
August 31, 2010 at 15:14:28
Set Var=%%~nF

At the command prompt enter For /? for further info.


Report •

#7
September 4, 2010 at 08:06:47
Thanks, perfect.

Report •


Ask Question