Copy content from subfolder using DOS

Solved
BadGamer Posted messages 694 Status Member -  
BadGamer Posted messages 694 Status Member -
Hello,

What I want to do should be super simple but I can't manage it...
Basically, I have a folder "Photos" containing subfolders
2010
2011
2012
And in each directory, there are .png photos. I would like to run this command to merge the subfolders into a new one

copy .....\Photos\*\*.png .....\PhotosFusion\


But I feel like the \*\ to say "all directories" isn't working... any idea? =)

Configuration: Windows 7 / Chrome 23.0.1271.97

3 answers

  1. dourd1 Posted messages 367 Status Member 39
     
    I believe you need to use xcopy to copy the subdirectories

    and from memory I would say

    xcopy /E c:\toto\*.* d:\"your backup folder"

    or /s if you don't want the empty directories

    it should then copy all the subdirectories of toto and the files into the backup folder
    but I don't know if that's exactly what you want to do

    nicolas
    2
    1. BadGamer Posted messages 694 Status Member 133
       
      I would like to merge the contents of all the subdirectories of a folder. Basically, I have:

      Toto> Toto1> 1.png 2.png Toto2> 3.png 4.png 


      And I would like to have my photos 1, 2, 3, and 4 in the same directory.
      0
  2. dourd1 Posted messages 367 Status Member 39
     
    With PowerShell, you can use the -container parameter of copy-item:

    copy-item source destination -recurse -container:$false

    The line above will copy all files from <source> "flat" into the
    <destination> directory. The only downside is that it will also recreate the directories
    that are at the root of <source> (even though these directories will appear empty
    in <destination>, all files being copied to the root of
    <destination>).

    Another way to proceed that does not have this drawback:

    dir source -recurse | where {!$_.PSIsContainer} | foreach {copy $_.fullname
    destination}

    or

    XCOPY with a FOR.

    Example:
    FOR /R c:\rsource %%a IN (.) DO XCOPY %%a c:\rdestination /Y

    to be done in a batch

    here is what should allow you to do what you want

    please confirm whether this is ok or not so that I can make it available on my site

    nicolas
    0
  3. BadGamer Posted messages 694 Status Member 133
     
    Super, thanks! The solution was that! Here is my bat file:

    FOR /R C:\RepSource %%a IN (.) DO XCOPY %%a C:\RepArrive /Y
    pause

    the pause is probably unnecessary
    Thanks a lot =)

    Edit: actually, I lost 100MB between the source and destination directories... I'll look for the problem...
    Edit2: I started with 719 items and ended up with 588... is there an option to rename instead of deleting in case of the same name? Because I think the problem comes from files with the same name...
    0
    1. BadGamer Posted messages 694 Status Member 133
       
      Otherwise, I don't care about the name, we should first rename all the files in the subfolders...
      I'm trying this log
      0
    2. dourd1 Posted messages 367 Status Member 39
       
      Did you manage to do what you wanted?
      0
    3. BadGamer Posted messages 694 Status Member 133
       
      Yes, I searched for ".png", copied and pasted everything, and then did the same for .jpg… a bit of a haphazard solution, but it works.
      0