Hello All,
I tried copying the content of a txt file into multiple txt files in a destination folder but not getting the expected result. I've tried :
"Copy my file.txt floder\×.txt" but it's not updating all the txt files. Can someone help me out?
How to copy a txt file into multiple txt files in a destination folder
Moderator: DosItHelp
Re: How to copy a txt file into multiple txt files in a destination folder
why would you expect it to?
Copy cannot append to files - it creates or overwrites them, and as it can only create A destination file, it cannot accept wildcards for the Destination file.
In other words, whilst copy can copy multiple files into a single file, it cannot copy a single file into multiple files.
I suggest referring to the help output of commands within cmd.exe
There also sites like https://ss64.com/nt/ that offer detailed command explanations and usage examples.
Re: How to copy a txt file into multiple txt files in a destination folder
Code: Select all
copy file.txt folder\file1.txt
copy file.txt folder\file2.txt
copy file.txt folder\file3.txt
copy file.txt folder\file4.txt
Saso
Re: How to copy a txt file into multiple txt files in a destination folder
1.bat
Code: Select all
@echo off
set "OldFile=C:\Test\1.txt"
set "NewFolder=C:\Test\To"
for /f "delims=" %%i in ('dir /b /a-d "%NewFolder%\*.txt"') do (
>>"%NewFolder%\%%i" echo,
>>"%NewFolder%\%%i" type "%OldFile%"
)