List.txt contains a list of paths. It was made using: dir /s /b file.exe
I want to copy new file.exe to each path located inside list.txt file.
My goal is to replace old file.exe with newer verison.
EDIT:
Or, even better... How to copy file to each path dir /s /b file.exe returns.
be sure to test with echos before doing a "live" run. @echo off & setlocal
for /f "tokens=*" %%a in ('dir /b /s file.exe') do copy /y \newver\file.exe %%~dpa(test method - dry run)
@echo off & setlocal
for /f "tokens=*" %%a in ('dir /b /s file.exe') do echo copy /y \newver\file.exe %%~dpa
@echo off if "%1"=="" goto :EOF
set sourcefile=%1
for /f "tokens=*" %%f in ('dir C:\%sourcefile% /s /b') do (
echo xcopy "%sourcefile%" "%%f" /D
)
If sourcefile and targetfile happen to be the same, a copy would not occur since only newer files are copied. Sourcefile without whitespaces, or code change is needed.
Thank you both. nbrane's version is the one I'm going to use since the file name is always the same, and it needs to be overwriten each time, despite it's newer or not.
I was wondering how to cut off the file name from path, and now I learned. :)
Once again, thank you.
Regards
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |