Avatar of elwayisgod
elwayisgod
Flag for United States of America asked on

XCOPY

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....
Microsoft DOSWindows BatchVB Script

Avatar of undefined
Last Comment
LeeeRussell

8/22/2022 - Mon
AustinComputerLabs

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?
fireline1082

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.
ragnarok89

I don't think this is possible with xcopy.

You could just create a batch file to do this, or try xxcopy
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
elwayisgod

ASKER
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.
elwayisgod

ASKER
Is it possible with any other scripting like VB?
Rick

for /f "tokens=*" %a in ('dir /b /s /a-d "C:\users\darcy\Music') do @copy "%a" "C:\Music"
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
ragnarok89

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Rick

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"
Rick

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"
elwayisgod

ASKER
XXCOPY is not recognized as a operable program.....
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
elwayisgod

ASKER
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.
elwayisgod

ASKER
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?
LeeeRussell

Looks like a typo on the XCOPY one:

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

Try that instead.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
LeeeRussell

Please ignore my last comment, I hadn't heard of xxcopy before.