Wednesday, 15 April 2015

batch file - How to loop over directories with dots and spaces in their names? -



batch file - How to loop over directories with dots and spaces in their names? -

i have directory contains other directories specific pattern. sub-directories start sequential number dot , space. comes string b8y, equal , after random number. sample folder structure:

1. b8y000037938 2. b8y000044394 3. b8y000069434 4. b8y000078238 5. b8y000094627

now want loop on directories phone call script. utilize code task:

for /d %%t in (%main_folder%\*b8y*) ( echo "processing %%~nt" if "%~2"=="" ( phone call %path_to_my_script% %%~ft ) else ( phone call %path_to_my_script% %%~ft %2 ) )

if not pass sec parameter script, expect output this:

processing 1. b8y000037938

instead output is

processing 1

and sec script called sec parameter not set , b8y000037938.

when replace .<space> - works expected, think .<space> causing problem. don't want rename folders manually , if can done automatically, prefer not changing folder-names. know, how accomplish task?

try using %%~nxt in place of %%~nt.

~nt means name of t ~nxt means name extension - , .whatever extension...

batch-file cmd

No comments:

Post a Comment