0

Can someone help me with a batch script or powershell script. I am a noob in a programing. I have a few folders and subfolders and sub subfolders. Only the name of tha main folder "Folder1" is different. All other subfolders are with the same name. The sub subfolders are also different. The structure of all folders is something like this:

Folder1
  -folderAAA
  -folderBBB
     -folderBBB111
     -folderBBB222
  -folderCCC
Folder2
  -folderAAA
  -folderBBB
     -folderBBB111333
     -folderBBB222333
  -folderCCC
.......

I have a lot of main folder like "Folder1 and Folder2" I need a script who to research main folders "Folder1, folder2..." and when find "folderBBB" to go inside this folder and to copy the folders, that are inside to different place, like folder "Uploads" or something.

MC ND
  • 69,615
  • 8
  • 84
  • 126
  • Please specify your problem and show us what you have got so far. – fuesika Mar 11 '14 at 17:09
  • 4
    Questions describing your requirements and asking someone to write the code for you or explain how to write the code are off-topic for Stack Overflow. Please identify a specific problem or question about programming. Include attempted solutions, an explanation of how the results differ from the desired results, and any error messages you receive. Please read the [About](http://www.stackoverflow.com/about) page and [this advice on asking good questions](http://stackoverflow.com/help/how-to-ask). – Adi Inbar Mar 11 '14 at 20:19
  • Hi, thank you for your respond. I need someone to write the script if is possible. I am shure, that this script will help a lot of people. I had a script, who copy only files with extensions like ".exe" or what you want. – user3406874 Mar 12 '14 at 10:05
  • $docFiles = Get-ChildItem -Path "C:\Users\aaa\Desktop\1" -Recurse | Where-Object {$_.Attributes.ToString() -notlike "*Directory*" -and ($_.Name -like "*.exe")} | Sort-Object -Unique; $docFiles | ForEach-Object { Copy-Item -Path $_.fullname -Destination "C:\Users\aaa\Desktop\222" }; – user3406874 Mar 12 '14 at 10:07

1 Answers1

1

Start here:

How do I get only directories using Get-ChildItem?

Then go on to

http://technet.microsoft.com/en-us/library/ee156818.aspx

And you should be able to figure out how list directories and how to copy contents.

If you have a script that is almost working, but you still have trouble then post a more detailed description.

Community
  • 1
  • 1
  • $docFiles = Get-ChildItem -Path "C:\Users\aaa\Desktop\333" -Recurse -include "folderBBB" | where {$_.Attributes -eq 'Directory'} ; $docFiles | ForEach-Object { Copy-Item -Path $_.fullname -Destination "C:\Users\aaa\Desktop\4444" }; – user3406874 Mar 12 '14 at 10:34
  • This is my script, it is something like previous one. I just change some settings, but it is not working. The script only created a new folder "folderBBB" and the folder is empty. I need the folder to be full with all subfolders. – user3406874 Mar 12 '14 at 10:36