Re: Copy multiple files into a single file - xcopy?

Tech-Archive recommends: Fix windows errors by optimizing your registry



JornyO wrote:
I tried the code you suggested by copying and pasting it into a text file and then changing the extension to .bat. I tried running it twice, once by double-clicking on the Batch file icon, and once from Command Prompt. Both times I got the same result: a 1KB file called Collect.txt in C:\ with a single line of text that says: "Snapshot taken on 03/15/2007 at 9:00" That batch file was in the parent folder whose subfolders contain the text files I want copied into a single file.

Did I miss something? Perhaps my limited knowledge of coding and scripting is making blind to something that ought to be obvious.



"Pegasus (MVP)" wrote:

@echo off
set HomeFolder=c:\temp

Echo Snapshot taken on %date% at %time:~0,5% > c:\Collect.txt
call :Sub %HomeFolder%
for /F "tokens=*" %%* in ('dir /s /b /ad') do call :Sub %%*
notepad c:\Collect.txt
goto :eof
:Sub
pushd "%*"
if exist *.txt (
echo. >> c:\Collect.txt
echo Folder=%* >> C:\Collect.txt
echo ==================== >> c:\Collect.txt
for %%b in (*.txt) do (
echo %%b >> c:\Collect.txt
type "%%b" >> c:\Collect.txt
)
)
popd


While you're waiting for Pegasus to explain the esoterica of command-line programming, try editing the second line of your batch file to read:

set HomeFolder=c:\Data

(assuming that C:\Data is parent folder whose subfolders contain the text files you want copied into a single file; otherwise, use the correct folder name)

--
Lem MS MVP -- Networking

To the moon and back with 64 Kbits of RAM and 512 Kbits of ROM.
http://en.wikipedia.org/wiki/Apollo_Guidance_Computer
.



Relevant Pages

  • Re: How to program Enable, Disable drivers?
    ... Use this batch file to enable or disable a device ... setlocal enabledelayedexpansion ... echo Syntax: Device enable / disable ... Open a Command Prompt. ...
    (microsoft.public.windowsxp.general)
  • Re: Files deleted but free space doesnt increase
    ... The strange thing is that when I give you a self-logging batch file to ... echo %date% %time%> c:\test.txt ... command prompt to do that, ... deleting the files? ...
    (microsoft.public.windows.file_system)
  • Re: Script to MOVE file and leave a Shortcut to new location
    ... It also avoids re-creating any already existing shortcuts, so you could run it after your subsequent robocopy cleanup runs. ... @echo off ... Since your description about the source and target folders is rather vague, you may have to tweak the above batch file a little in order to suit your environment. ... You must test the batch file from the Command Prompt. ...
    (microsoft.public.windows.server.scripting)
  • Re: Change time by one hour
    ... current time from the command prompt, but I think this is beyond my ... You can get them to run this batch file: ... echo Setting the time to %NewTime% ...
    (microsoft.public.windowsxp.general)
  • Re: DOS Environment not working
    ... It just shows the variables set by windows on startup, ... The batch file does not fail because I ... installed a errorlevel statement to echo a message.... ... I run the batchfile at the command prompt, but when I check the variables: ...
    (microsoft.public.windowsxp.general)