Solved

XCOPY

Posted on 2011-03-08
14
501 Views
Last Modified: 2012-05-11
I need to copy all files of a directory and all of its subdirectories to a specified location.  However I don't want the folders.  I just want all the files.  Basically trying to flatten out a structure.

Source Dir:  C:\users\darcy\Music

Target Dir:  C:\Music

Can I use xcopy?  I can't use robocopy as it's a work computer....
0
Comment
Question by:elwayisgod
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 13

Expert Comment

by:AustinComputerLabs
ID: 35073578
Are you saying you do not want any of the folders inside of the music dir, just all of the files dumped into a single directory?
0
 
LVL 3

Expert Comment

by:fireline1082
ID: 35073624
I do not  think u can do (files and subs) using xcopy.

But u can do it using VHS script where u need to loop through the folders and copy the files.

I have similar script to delete files (not copy). I will pass it to you tomorrow when I reach the office.

Copy should be similar.
0
 
LVL 8

Expert Comment

by:ragnarok89
ID: 35073629
I don't think this is possible with xcopy.

You could just create a batch file to do this, or try xxcopy
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:elwayisgod
ID: 35073636
Yes.. I need to just take all the files from a Dir and all it's Sub Dir's and dump them into a single directory.
0
 

Author Comment

by:elwayisgod
ID: 35073666
Is it possible with any other scripting like VB?
0
 
LVL 13

Expert Comment

by:Rick
ID: 35073669
for /f "tokens=*" %a in ('dir /b /s /a-d "C:\users\darcy\Music') do @copy "%a" "C:\Music"
0
 
LVL 8

Accepted Solution

by:
ragnarok89 earned 250 total points
ID: 35073742
XXCOPY C:\*.*  D:\mydocs\   /SL
0
 
LVL 13

Expert Comment

by:Rick
ID: 35073784
Sorry... my previous post didn't work in Windows 7.

Try this:

Open a dos window:
navigate to C:\users\darcy\Music
Enter this command and press enter:

  for /f "tokens=*" %a in ('dir /b /s /a-d') do @copy "%a" "c:\Music"
0
 
LVL 13

Expert Comment

by:Rick
ID: 35073824
No wonder it didn't work... I forgot to close quotes!
Try this (you won't need to navigate to the root directory):

for /f "tokens=*" %a in ('dir /b /s /a-d "C:\users\darcy\Music"') do @copy "%a" "C:\Music"
0
 

Author Comment

by:elwayisgod
ID: 35074976
XXCOPY is not recognized as a operable program.....
0
 

Author Comment

by:elwayisgod
ID: 35074992
Rick,

When I try yours I get:

C:\Temp>call music.bat > sam.log
\Users\Darcy\Music"') do @copy "\MusicFiles" was unexpected at this time.
0
 

Author Comment

by:elwayisgod
ID: 35075198
Rick,

If i just run what you said and not put it in a .bat file and then call it, it works.. however there are duplicates and it stops and asks me to overwrite or not... Is there a parameter I can put in so it automatically overwrites?
0
 
LVL 6

Expert Comment

by:LeeeRussell
ID: 35080492
Looks like a typo on the XCOPY one:

XCOPY C:\*.*  D:\mydocs\   /SL

Try that instead.
0
 
LVL 6

Expert Comment

by:LeeeRussell
ID: 35080511
Please ignore my last comment, I hadn't heard of xxcopy before.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question