A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about Copy multiple files from different folders to 1 folder was one problem in server stack that need for a solution. Below are some tips in manage your windows server when you find problem about windows, copy, robocopy, copying, xcopy.
i’m looking for a sollution to copy multiple files from different folders to 1 folder.
What I have is that I need to copy files from
c:CustomersfolderAfolderBfiles
copy to e:FolderBfiles
The problem is that the “Customers” everytime is different. Also FolderA is different. Only FolderB is the same.
I’ve tried it with robocopy or with copy. But I always have to fill in the Customers name.
Can some one help me?
So I tried it into powershell
and i came to
Copy-Item -Path C:customer -Recurse -filter *.xls -Destination e:folderB -Force
only with this i filter to files and all the folders al copied. And i only want the files in it.
You can use the FOR /D command to loop through the directories in a path:
FOR /D %%I IN (C:Customers*) DO (
REM %%I is "C:CustomersFolderA", etc.
robocopy.exe /E "%%IFolderBfiles" "C:FolderBfiles"
)
Let’s assume the directory C:Customers contains:
- A. Datum Corporation
- AdventureWorks Cycles
- Alpine Ski House
- Awesome Computers
- Baldwin Museum of Science
- Blue Yonder Airlines
If we run this simple command script:
FOR /D %%I IN (C:Customers*) DO (
ECHO %%I
)
We get this output:
C:CustomersA. Datum Corporation
C:CustomersAdventureWorks Cycles
C:CustomersAlpine Ski House
C:CustomersAwesome Computers
C:CustomersBaldwin Museum of Science
C:CustomersBlue Yonder Airlines
So taking that a step further, this command script:
FOR /D %%I IN (C:Customers*) DO (
robocopy.exe /E "%%IFolderBfiles" "C:FolderBfiles"
)
Would run the following commands in sequence:
robocopy.exe /E "C:CustomersA. Datum Corporation" "C:FolderBfiles"
robocopy.exe /E "C:CustomersAdventureWorks Cycles" "C:FolderBfiles"
robocopy.exe /E "C:CustomersAlpine Ski House" "C:FolderBfiles"
robocopy.exe /E "C:CustomersAwesome Computers" "C:FolderBfiles"
robocopy.exe /E "C:CustomersBaldwin Museum of Science" "C:FolderBfiles"
robocopy.exe /E "C:CustomersBlue Yonder Airlines" "C:FolderBfiles"
The output, of course, would be the result of each robocopy command.