Copy content from subfolder using DOS
Solved
BadGamer
Posted messages
694
Status
Member
-
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
But I feel like the \*\ to say "all directories" isn't working... any idea? =)
Configuration: Windows 7 / Chrome 23.0.1271.97
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
-
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 -
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 -
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...-
I don't think I will try to look into this in the morning if I find an answer for you.
Otherwise, try to see with robocopy, maybe there’s an option that will work
http://dourd1.free.fr/wordpress-3.0.3/wordpress/?p=29 -
-
-
-