?
Solved

XCOPY

Posted on 2011-03-08
14
Medium Priority
?
543 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

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 1000 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses

807 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