Solved

XCOPY

Posted on 2011-03-08
14
511 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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