[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 answers

  1. AmonDiaC Posted messages 2 Status Member
     
    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
  2. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 660
     
    hello
    and with?
    FOR /d %%i in ("D:\Application Data\*.*") do @copy "D:\UnPDF.pdf" %%i 
    0
  3. fr
     
    "putting quotes to accept spaces should work"
    0
  4. AmonDiaC Posted messages 2 Status Member
     
    No, putting quotes in the parentheses of the for in () does not work to accept spaces.
    0
  5. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 660
     
    With this command, it correctly displays the directories contained in .\..\Application Data\*.
    C:> for /D %a in ("..\..\Application Data\*.*") do @echo %a
    0
  6. francky
     
    modifier_l'espace_le_remplacer_par_la_barre_8_sur_le_clavier_et_normalement_cela_devrait_passer
    0
  7. Anonymous user
     
    Hi there!
    Isn’t "application data" stored in a predefined variable?
    0