BizTalk Blog by Chris Han

System Design for Enterprise Agility,

  Home  |   Contact  |   Syndication    |   Login
  68 Posts | 9 Stories | 173 Comments | 79 Trackbacks

News

Article Categories

Archives

Post Categories

Image Galleries

BizTalk Bloggers

BizTalk on MSDN

Patterns & Architecture

SharePoint

It all started with letting iTunes "organize" my video files. For some reason, it decided to create a subfolder for each of my files. Errrrrrr!

Now I'm looking for a way to copy the files in subdirectories back to a single directory. By some online searching and error-trial, here's my solution:

For /r %d "C:\source dir" in (*) do copy "%d" "E:\dest dir"

It's different than a suggested solution I found online something like:

For /r %d "C:\source dir" in (.) do copy %d\*  "E:\dest dir"

However the period character doesn't work for me. According to the explaination, the (.) means all subdirectories, so the %d\* means all files in each subdirectories. But reality is it added a \.\ in the fully path name of the source, the result like this:

copy "C:\source dir\.\video.mp4" "E:\dest dir"

while it should be:

copy "C:\source dir\video.mp4" "E:\dest dir"

Any way, this format works for me, hopefully, same you some time.

For /r %d "C:\source dir" in (*) do copy "%d" "E:\dest dir"

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Wednesday, January 06, 2010 9:54 PM

Feedback

# re: How to copy all files in subdirectories without directory structure 1/8/2010 12:50 PM Vlad
Hi Chris,

When I ran on WinXP or Server 2003:
For /r %d "C:\whatever" in (*) do copy "%d" "E:\whatever"
I got the following error message:
"C:\whatever" was unexpected at this time.

Can you give me a hint what is wrong?

Thanks,
Vlad

# re: How to copy all files in subdirectories without directory structure 1/8/2010 1:38 PM Vlad
There is a wrong order of parameters.

Use the following command:

For /r "C:\source dir" %d in (*) do copy "%d" "E:\dest dir"

Instead of:

For /r %d "C:\source dir" in (*) do copy "%d" "E:\dest dir"

# re: How to copy all files in subdirectories without directory structure 7/17/2010 9:37 AM JobGraphs
Hi Chris,
Check out Biztalk Global job trends like No. of jobs in different countries, salary comparison, job roles, skills and exp. required at http://jobgraphs.com/biztalk/

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: