Computing.Net > Forums > Programming > Copy files with batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Copy files with batch

Reply to Message Icon

Name: lekfir
Date: January 1, 2009 at 15:09:43 Pacific
OS: Windows XP
CPU/Ram: a
Product: A / A
Subcategory: Batch
Comment:

Hello,
I am trying to write a script that copies all files in the directory tree to a folder without the folders. Only teh files inside them.
For example,
I have Folder1\Folder2\Folder3
and I want to copy all files in the 3 sub folders into Folder4.
I tried this but it fails:
For %%J in (*.*) Do (XCOPY "C:\Folder1\%%J" "C:\Folder2\" /Y)
Please Help



Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: January 1, 2009 at 17:46:04 Pacific
Reply:


for /f "delims=" %%a in ('dir drive:\folder1\ /a-d /b /s') do copy "%%~fa" drive:\folder4\


0

Response Number 2
Name: lekfir
Date: January 1, 2009 at 23:13:43 Pacific
Reply:

Thanks! That rocks!


0

Response Number 3
Name: lekfir
Date: January 2, 2009 at 05:16:34 Pacific
Reply:

Another question,
Asuuming That I want to copy only files that Starts with 'Test'.
For example,
Copy only teh following files from all folders and sub-folders:
TestGen1.txt
TestGen56Big.csv...
Is it possible?


0

Response Number 4
Name: Judago
Date: January 2, 2009 at 05:42:05 Pacific
Reply:

Yep, copy also supports wild cards.


for /f "delims=" %%a in ('echo "drive:\path\folder1"^&^&dir "drive:\path\folder1\" /ad /b /s') do >nul 2>&1 copy "%%~a\test*" "drive:\path\folder4"


0

Response Number 5
Name: lekfir
Date: January 2, 2009 at 13:57:53 Pacific
Reply:

Thanks! You are great!
I will check and tell you my results in the next days!
Thanks again and come to visit ;-)


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Backup strategy and bat f... running batch file as loc...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Copy files with batch

copy files only with a particular name www.computing.net/answers/programming/copy-files-only-with-a-particular-name/19939.html

editing text file with batch file www.computing.net/answers/programming/editing-text-file-with-batch-file/15231.html

copy file with batch www.computing.net/answers/programming/copy-file-with-batch/16615.html