Solved

XCOPY

Posted on 2011-03-08
14
480 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now