Guest Rob Posted August 19, 2007 Posted August 19, 2007 Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. I would like to write a batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. This is so that I can select them all at once in an application. I have used xcopy to make batch files in the past, and I know what to do if I wanted the tree structure maintained in the target, but I don't. I want all files to be in a single directory. Any help most welcome. Thanks. Rob
Guest Pegasus \(MVP\) Posted August 19, 2007 Posted August 19, 2007 Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. "Rob" <f8YRm9@spambobLEAVETHISBITOUT.net> wrote in message news:j8rgc3h3i9b7umju0rfc69ffk6ksuik1ro@4ax.com... >I would like to write a batch file to copy all TXT files in a given > directory and all subdirectories to a single target directory. > > This is so that I can select them all at once in an application. > > I have used xcopy to make batch files in the past, and I know what to > do if I wanted the tree structure maintained in the target, but I > don't. I want all files to be in a single directory. > > Any help most welcome. > > Thanks. > > Rob > You could use xxcopy.exe. It has a function called "flatten" a directory tree. You can download it from a number of sites.
Guest Poprivet Posted August 19, 2007 Posted August 19, 2007 Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. Pegasus (MVP) wrote: > "Rob" <f8YRm9@spambobLEAVETHISBITOUT.net> wrote in message > news:j8rgc3h3i9b7umju0rfc69ffk6ksuik1ro@4ax.com... >> I would like to write a batch file to copy all TXT files in a given >> directory and all subdirectories to a single target directory. >> >> This is so that I can select them all at once in an application. >> >> I have used xcopy to make batch files in the past, and I know what to >> do if I wanted the tree structure maintained in the target, but I >> don't. I want all files to be in a single directory. >> >> Any help most welcome. >> >> Thanks. >> >> Rob >> > > You could use xxcopy.exe. It has a function called "flatten" > a directory tree. You can download it from a number of > sites. There are a couple of revs with bugs; get it from xxcopy.com to be sure of getting the latest. Pop`
Guest - Bobb - Posted August 20, 2007 Posted August 20, 2007 Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. "Rob" <f8YRm9@spambobLEAVETHISBITOUT.net> wrote in message news:j8rgc3h3i9b7umju0rfc69ffk6ksuik1ro@4ax.com... >I would like to write a batch file to copy all TXT files in a given > directory and all subdirectories to a single target directory. > > This is so that I can select them all at once in an application. > > I have used xcopy to make batch files in the past, and I know what to > do if I wanted the tree structure maintained in the target, but I > don't. I want all files to be in a single directory. > > Any help most welcome. > > Thanks. > > Rob > I used to do that long ago - From DOS prompt: ( Start- Run- CMD ) CD \ ( just so we both assume same thing) Md newdir cd newdir Xcopy/s c:\sourcepath\*.txt *.* Will copy all *.txt files from source path and subfolders (use C:\ for entire drive) to C:\newdir using same filenames. Only a problem if dup filenames. ( /c would be handy to have it keep going even after error) Also /l or /f may be useful. =========== From cmd prompt do xcopy/? for syntax/options help. If manual one time, just cd to that folder first. =========== Bobb
Guest Pegasus \(MVP\) Posted August 20, 2007 Posted August 20, 2007 Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. "- Bobb -" <bobb@noemail.123> wrote in message news:%231nSIRs4HHA.484@TK2MSFTNGP06.phx.gbl... > > "Rob" <f8YRm9@spambobLEAVETHISBITOUT.net> wrote in message > news:j8rgc3h3i9b7umju0rfc69ffk6ksuik1ro@4ax.com... >>I would like to write a batch file to copy all TXT files in a given >> directory and all subdirectories to a single target directory. >> >> This is so that I can select them all at once in an application. >> >> I have used xcopy to make batch files in the past, and I know what to >> do if I wanted the tree structure maintained in the target, but I >> don't. I want all files to be in a single directory. >> >> Any help most welcome. >> >> Thanks. >> >> Rob >> > I used to do that long ago - > From DOS prompt: ( Start- Run- CMD ) > CD \ ( just so we both assume same thing) > Md newdir > cd newdir > Xcopy/s c:\sourcepath\*.txt *.* > Will copy all *.txt files from source path and subfolders (use C:\ for > entire drive) to C:\newdir using same filenames. Only a problem if dup > filenames. ( /c would be handy to have it keep going even after error) > Also /l or /f may be useful. > =========== > From cmd prompt do xcopy/? for syntax/options help. If manual one time, > just cd to that folder first. > =========== > Bobb > > Your command will maintain the existing folder structure. This is NOT what the OP requires.
Guest Rob Posted August 20, 2007 Posted August 20, 2007 Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. Re: Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. On Mon, 20 Aug 2007 07:36:39 +0200, "Pegasus \(MVP\)" <I.can@fly.com> wrote: > >"- Bobb -" <bobb@noemail.123> wrote in message >news:%231nSIRs4HHA.484@TK2MSFTNGP06.phx.gbl... >> >> "Rob" <f8YRm9@spambobLEAVETHISBITOUT.net> wrote in message >> news:j8rgc3h3i9b7umju0rfc69ffk6ksuik1ro@4ax.com... >>>I would like to write a batch file to copy all TXT files in a given >>> directory and all subdirectories to a single target directory. >>> >>> This is so that I can select them all at once in an application. >>> >>> I have used xcopy to make batch files in the past, and I know what to >>> do if I wanted the tree structure maintained in the target, but I >>> don't. I want all files to be in a single directory. >>> >>> Any help most welcome. >>> >>> Thanks. >>> >>> Rob >>> >> I used to do that long ago - >> From DOS prompt: ( Start- Run- CMD ) >> CD \ ( just so we both assume same thing) >> Md newdir >> cd newdir >> Xcopy/s c:\sourcepath\*.txt *.* >> Will copy all *.txt files from source path and subfolders (use C:\ for >> entire drive) to C:\newdir using same filenames. Only a problem if dup >> filenames. ( /c would be handy to have it keep going even after error) >> Also /l or /f may be useful. >> =========== >> From cmd prompt do xcopy/? for syntax/options help. If manual one time, >> just cd to that folder first. >> =========== >> Bobb >> >> > >Your command will maintain the existing folder structure. >This is NOT what the OP requires. Thanks to all. xxcopy did the trick. Rob
Recommended Posts