Eu tenho um arquivo fonteblue01.ambiente(arquivo de texto)
eu preciso copiaro textoneste arquivo e cole-o em todos os arquivos abaixo, mas salvando-oscom seu nome original.
blue02.environment
yellow01.environment
yellow02.environment
yellow03.environment
purple01.environment
purple02.environment
...
Alguém poderia me indicar um comando em lote que eu pudesse usar?
Responder1
Experimente isto:
#!/bin/bash
# the file you want the content to be copied
master=/your_dir/master_file
# get the content
content="$(cat $master)"
# loop the files .environment
for file in /your_dir/*.environment; do
# if the file is not the master file copy the content
[ "$file" != "$master" ] && echo "$content" > "$file"
done
Responder2
E quanto a issoarquivo em lote:
rem // Define constants here:
set "_ROOT=." & rem // (path to root directory; `.` is current, `%~dp0.` is batch file parent)
set "_MASK=*.environment" & rem // (pattern to match files to process)
set "_MASTER=blue01.environment" & rem // (name of master file)
rem // Change to root directory:
pushd "%_ROOT%" && (
// Iterate over all matching files:
for %%I in ("%_MASK%") do @(
rem // Exclude master file to be overwritten:
if /I not "%%~nxI" == "%_MASTER%" (
rem // Copy master file onto current file:
copy /Y "%_MASTER%" "%%~I" > nul
)
)
rem // Return from root directory:
popd
)