-1

I have a batch file that helps me in install multiple pieces of software from a shared folder.

It's working well with software whose names don't contain spaces, but I need it to work with software does.

this code is working fine because thereis no space in the software name (firefox.exe):

for /f %%a in ('dir /s /b \\sharedfolder\*firefox*.exe') do %%a

if i trying the same code with a software that has space in the name, it's not working,

for example for /f %%a in ('dir /s /b \\sharedfolder\mozzila *firefox* 36.0.4.exe') do %%a

please look at the software name and you will understand what i meant.

2 Answers2

0

Try something like this:

for /f %a in ('/s /b \\sharedfolder\*firefox*.exe') do "%a"

You seem to have doubled up your %'s and would need to quote the variable for it work.

GregL
  • 9,370
  • 2
  • 25
  • 36
0
rem    ↓↓↓↓↓↓↓↓↓
for /f "delims=" %%a in ('dir /s /b "\\sharedfolder\mozzila *firefox* 36.0.4.exe"') do (
    rem  ↓   ↓  note double quotes  ↑                                           ↑    
    ECHO "%%a"
)

    

Explanation:

  • "delims=" option suppresses tokenization of dir /B output;
  • Double Quotes: if a single parameter contains spaces, you can still pass it as one item by surrounding in "quotes" - this works well for long filenames;
  • ECHO "%%a": an operational command is merely displayed for debugging purposes; remove the word ECHO no sooner than debugged!
JosefZ
  • 1,564
  • 1
  • 10
  • 18