Solved question about a parameter for an xcopy-command in a batfile


Samun

Member
Member
Local time
7:41 PM
Posts
37
OS
Windows 11
Hey guys. I have a bat-file that copies "test.bat" into all subfolders of a target folder.

cd "target folder"
for /r /d %%I in (*) do xcopy "sourcefolder\test.bat" "%%~fsI" /H /K

Let's say there are 100 subfolders in the target-folder. Test.bat has to be copied into each of those 100 subfolders, but only once, not into THEIR subfolders. Right now the command copies test.bat a million times, not 100 times. I go over the xcopy parameters, but that leaves me puzzled.

Is there a parameter I can use to do that?
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    CPU
    Ryzen 5 2600x
    Motherboard
    X470 Gaming Plus
    Memory
    32GB DDR4
    Graphics Card(s)
    RTX 3060
    Sound Card
    My last one was Soundblaster 16
    Monitor(s) Displays
    2
    Screen Resolution
    2560x1440 both; 120Hz and 75Hz
    Hard Drives
    SSD M.2 2TB with System, and a HDD 8TB for stuff
I think you could just get rid of the /r in your for statement
 

My Computer

System One

  • OS
    Linux Mint
    Computer type
    Laptop
    Manufacturer/Model
    System76 Lemur Pro
ooooooooooooh.....

Thank you, sir. You saved me a lot of time and nerves! :D

-closed-
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    CPU
    Ryzen 5 2600x
    Motherboard
    X470 Gaming Plus
    Memory
    32GB DDR4
    Graphics Card(s)
    RTX 3060
    Sound Card
    My last one was Soundblaster 16
    Monitor(s) Displays
    2
    Screen Resolution
    2560x1440 both; 120Hz and 75Hz
    Hard Drives
    SSD M.2 2TB with System, and a HDD 8TB for stuff

Latest Support Threads

Back
Top Bottom