how to copy just text files from subfolders ?

January 15, 2011 at 07:01:02
Specs: Windows XP
hi
i have a folder which contains alot of subfolders with ".txt" files, how can i copy just the fiels that ends with txt to a specific folder without creating the subfolders in the destination folder.

i tried xcopy /s c:\bck\*.txt c:\test but it created the the subfolders in the destinantion.
in addition is there a way to overwrite the files in the destinantion folder if it already exist ?

thanks for the help
elad


See More: how to copy just text files from subfolders ?

Report •


#1
January 15, 2011 at 10:35:10
It seems we need to create a Program wich sends "Spiders", of itself to all Directories then they indvidually use Copy *.txt to desired destination and erase themselves that way you only would get only .txt without the Folder/Directory tagging along im working on it now but its hard... maybe not possible in Batch..

Report •

#2
January 15, 2011 at 10:46:25
Untested:
for /r "c:\bck" /d %%a in (.) do @copy /y "%%a\*.txt" c:\test

How To Ask Questions The Smart Way


Report •

#3
January 15, 2011 at 11:14:07
damit why would they include a command to create directory without the files WHY couldent it be reversed, damn irony at its finest...

Razor the command dident work :( it creates a File with the Code of one of the .txt file within it the file is Nothing just WhiteFile edit in notepad it got the text of one of the .txt files and it is unable to copy 7/10th of all .txt messages accoring to cmd



Report •

Related Solutions

#4
January 15, 2011 at 12:34:12
Just tested what I posted; it works. Either the account you're using doesn't have access to 7/10th of all files, or 7/10ths of them share a name.

EDIT: Unless you're worried about the cmd text dump? Don't be, it's largely frivolous.

How To Ask Questions The Smart Way


Report •

#5
January 16, 2011 at 05:24:04
I have no idea why you say it works, cause xcopy allow me to find all .txt file and im Main adminstrator + in the end it does not create a folder it creates a white file with the content of one of the .txt file, and the file type name is : File its not a folder :(,

Report •

#6
January 16, 2011 at 05:27:21
The folder needs to exist before you run the script.

How To Ask Questions The Smart Way


Report •

#7
January 16, 2011 at 05:31:37
Thanks alot so faar but, it does work if one make the folder for it to copy into, but how to get it to copy to the folder the .bat was run from instead of a specific folder? :D

Report •

#8
January 16, 2011 at 05:46:05
Replace c:\test with .

How To Ask Questions The Smart Way


Report •

#9
January 16, 2011 at 06:00:37
Wow man you did it!! Thanks alot!!! iv'e searched all over google for how tod i it but people say its impossible alot of people have tried to figure it out with batch and tried various thing.
non been, successfull untill now. You really are expert in batch and did the impossible :) , Again thanks alot much appriciated!!!

Report •

#10
January 17, 2011 at 12:38:01
is there a way that the command wouldnt appear in the cmd window - @echo off isnt working

Report •


Ask Question