[BATCH] Copy a file to multiple folders

AmonDiaC -  
 Anonymous user -
Bonjour,

I want to create a batch script that copies a PDF and pastes it into all folders of a specified path.

I have this:

FOR /d %%i in (D:\Application Data\*.*) do @copy "D:\UnPDF.pdf" %%i

And it doesn't work because of the space in the path "Application Data". If I use "ApplicationData", it works. But I absolutely need it to work with a space since this is just an example for copying a config file into an App Data folder.

Configuration: Windows / Vivaldi 2.2.1388.37

7 réponses

AmonDiaC Posted messages 2 Status Membre
 
For your information, I have already tested with quotes « » = it does not work.

And I cannot do a « cd D:... » beforehand because I plan to manipulate \\domaine.lan\...
0
dubcek Posted messages 18814 Registration date   Status Contributeur Last intervention   5 655
 
hello
and with?
FOR /d %%i in ("D:\Application Data\*.*") do @copy "D:\UnPDF.pdf" %%i 
0
fr
 
"putting quotes to accept spaces should work"
0
AmonDiaC Posted messages 2 Status Membre
 
No, putting quotes in the parentheses of the for in () does not work to accept spaces.
0
dubcek Posted messages 18814 Registration date   Status Contributeur Last intervention   5 655
 
With this command, it correctly displays the directories contained in .\..\Application Data\*.
C:> for /D %a in ("..\..\Application Data\*.*") do @echo %a
0
francky
 
modifier_l'espace_le_remplacer_par_la_barre_8_sur_le_clavier_et_normalement_cela_devrait_passer
0
Anonymous user
 
Hi there!
Isn’t "application data" stored in a predefined variable?
0