Script to add 4 named sub folders on creation of new folder

can anyone help me with a  script that creates 4 sub folders with specific names within  a folder when the new folder is created????

Looks like this question was asked and solved here:
http://stackoverflow.com/questions/17432796/create-folders-applescript

Similar Messages

  • Move a folder, sub-folders, and documents under that folder from one document library to another within a Workflow

    Hello,
    I'm building a workflow in SharePoint Designer 2010 (Unfortunately we are not on 13 yet), and in that workflow I need to move a folder (with all it's sub-folders and items) from one document library to another document library.
    I tried a copy item but that kept failing, I checked content type, columns, and permission and it all looks good.
    the other option I started looking into is to Create the folder in the document list and them move all the items under that folder to the new folder. However I can't figure out how to loop through each items in that folder.
    Has this issue been addressed? or does someone has a solution.
    I looked and searched and all I found was tutorials on moving single items into a folder, but not entire folders.
    Thanks
    Hani

    Why to take pain in creating a workflow that copies folders, sub-folders and all of its contents from one document library to another.
    Simply open your source and destination document library in Windows Explorer mode and start copying your folder, sub-folders and contents that you want to copy out of the box.
    You will find "Open with Explorer" button under the Library tab on the ribbon of document library.
    Please remember to click 'Mark as Answer' on the reply if it helps you

  • Creating new folders changes focus to new folder, how do I stop this?

    I have looked in the help file, searched the forum here. As usual I found next to nothing using the search function...
    So I will ask it. Sorry if it has been covered.
    I would like to make new folders to organize images. However I do not want LR to show me the contents (or lack there of...) After creating it. I want LR to stay in the folder I am currently in
    Does LR already do this? If not I will put it in the feature request area
    Thanks

    Not that I know of, but there's an easy workaround. After creating the new folder, hit the back arrow (the left arrow above and on the left of the film strip). This will take you back to where you just were.

  • Files removed from folders, added into a "new folder with items"

    Just found files missing from document folders in multiple places, all appear to have been moved to a single folder called "new folder with items" under my user folder. Folder structure all in tact - just files all (or rather nearly all) moved.
    I'm restoring from back up now but ***?! had this mac for a year with no issues until now. No major tinkering done on the mac to have caused such a dramatic issue.

    If the directory name were random (most likely not even readable), that would mean the file system is corrupted and in need to be repaired ASAP, but as the name is in plain english it seems it was assigned programmatically.
    As most Unix derivatives, Mac OS X has a program called fsck.
    Each time a disk is "mounted" fsck checks if the file system is in a consistent state. If "dangling" files are found, they are collected in a special directory called "lost+found".
    Apple could have changed fsck to create a directory "new folder with items" instead of "lost+found", but I think this is unlikely.
    Perhaps someone more familiar with fsck could confirm, but in the meantime I would not rule out other theories.
    P.S.
    The files could still have been selected from the "All my files" category on the sidebar which looks like "flat" directory as far as the finder is concerned.

  • Mail won't detect IMAP sub folders

    I have several subfolders in my INBOX (INBOX.read, INBOX.sent, INBOX.todo, ...). Mail.app doesn't detect those sub folderds on startup. Only way to access the sub folders is to create new sub folder for INBOX. When I close the Mail.app or lose network connection, I have to create again new sub folder to be able to expand the INBOX.
    This is really annoying and makes Mail.App unusable for me because Spotlight reindexes the subfolders every time When Mail.App detects them. Reindexing takes about 10 minutes and 100% of my processor time...
    I have been told that this bug has existed for a long time . Why doesn't it get fixed? What is the recommended workaround?
    15.2" PowerBook   Mac OS X (10.4.4)  

    Thanks for the clarification.
    Please confirm that About Mail reports version 2.0.5?
    Make sure to have quit Thunderbird and Mail, and then in the Finder open Home/Library, and duplicate the Mail folder, and drag the copy to your Desktop, strictly for temporary backup. Next open the original Mail folder, and find the IMAP account folder for this account, and delete it. Empty the trash following this.
    Next, open Home/Library/Preferences, and find the com.apple.mail.plist file, and drag it to the Desktop (where you will most likely later delete it).
    Start Mail, and re-enter/set up your account (this should have resulted in Mail opening as new -- if not post back immediately about that), and DECLINE to import anything, even if prompted to. Test, and let me know what you experience with the issue.
    This procedure should have little risk, since 1) you are using IMAP and messages on the server are not lost. 2) On My Mac mailboxes are not impacted, and 3) you have made a backup just in case.
    It is possible that your particular IMAP provider and Mail have some incompatibilities, but I am using two IMAP at the moment, and both work. However, they each appear to treat folders differently.
    All the best.
    Ernie

  • Script to find files with same names with in a folder and it sub folders.

    Looking for script to find files with same names with in a folder and it sub folders.

    Are you just looking to find if any two files underneath a folder have the same name?
    If you just want to know that a file named "whatever" exists in two folders, that's not too difficult, but you probably want to know the full path names.
    Here's one attempt:
    $ perl -MFile::Find -le 'find(\&w, "."); while (($n,$p)=each %file) {if(@{$p}>1){print join(" ",@{$p})}} sub w{push @{$file{$_}},$File::Find::name;}'That will print the pathnames on the same line of any files with the same name that appear anywhere underneath your current directory.
    It's a bit long for a "one-liner", but functional.
    Darren

  • Script Grant Full Access Permission on Multiple Folders and Sub-Folders

    Hi, I'm having a issue trying to run this script. 
    1.)It provides each folder with "Special" Permission over them. (Read, Write, Modify, Full control). Is there a way of making it "Full Control" Permission instead of special permission?
    or
    2.) Is there a way to make the Object Apply to "This Folder,sub folders and files" (when i change it manually this it changes to Full Control Access)?
    What I tried doing in the following script is removing the inheritance of the folder then applying its level of authentication. I do get some errors and I'm pretty sure it's has to do with some files being password protected.
    $domainG = "Domain\Group"
    $dir = "X:\Folder\Folder\*\SameName"
    $subfolder = Join-Path $dir "\*"
    $subsubfolder = Join-Path $subfolder "\*"
    $subsubsubfolder = Join-Path $subsubfolder "\*"
    $subsubsubsubfolder = Join-Path $subsubsubfolder "\*"
    $acl = Get-Item $dir |get-acl
    #This removes inheritance
    $acl.SetAccessRuleProtection($true,$true)
    $acl |Set-Acl
    # Gives full control
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule -ArgumentList @($domainG,"FullControl","Allow")
    $acl.SetAccessRule($rule)
    $acl |Set-Acl
    $acl = Get-Item $subfolder |Get-Acl
    # This adds full control to the subfolder
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule -ArgumentList @($domainG,"FullControl","Allow")
    $acl.SetAccessRule($rule)
    $acl |Set-Acl
    $acl = Get-Item $subsubfolder |Get-Acl
    # This adds full control to the sub sub folder
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule -ArgumentList @($domainG,"FullControl","Allow")
    $acl.SetAccessRule($rule)
    $acl |Set-Acl
    $acl = Get-Item $subsubsubfolder |Get-Acl
    # This adds full control to the sub sub subfolder
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule -ArgumentList @($domainG,"FullControl","Allow")
    $acl.SetAccessRule($rule)
    $acl |Set-Acl
    $acl = Get-Item $subsubsubsubfolder |Get-Acl
    # This adds full control to the sub sub sub subfolder
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule -ArgumentList @($domainG,"FullControl","Allow")
    $acl.SetAccessRule($rule)
    $acl |Set-Acl

    The constructor you are using for the FileSystemAccessRule will only apply to the object the ACE belongs to. To have it apply to anything else, you'll have to use the constructor with the following arguments:
    <Principal>, <Rights>, <InheritanceFlags>, <PropagationFlags>, <Type>
    The one you're using doesn't have the flags. Those two flags enumerations control two things that you'll see in the GUI: 'Applies To' and 'Only Applies to this Object'. To have the ACE apply to the folder, subfolders and files (and have it not show as 'Special'
    in the GUI), you'll want the InheritanceFlags as 'ContainerInherit, ObjectInherit' and the PropagationFlags as 'None'. Try this:
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule -ArgumentList @($domainG,"FullControl", "ContainerInherit, ObjectInherit", "None", "Allow")
    On a side note, check
    this module out. It greatly simplifies access control. If you're interested in it and have any questions, let me know.

  • How To Add Folders and Sub Folders

    I am brand new (1 week) to my new Mac (iMac). In my Windows-based PC I used to have, for example, a folder named PHOTOS followed by sub folders designating certain categories that work for me, such as, "Family", "Vacations" etc, and I would make sure that all my uploads from my camers went to the appropriate folder.
    I would like to accomplish the same thing in my Mac, but have no idea how to go about it. I do not even know how to create such folders and sub folders.
    Is someone out there who can help, please?

    pstoll
    In the Finder: File -> New Folder creates a new Folder. To nest a folder inside another one then simply drag the second one to the first.
    But if you're trying to organise your photos, there's a much better way to do that on your Mac. Check out iPhoto It's a photo manager that's integrated throughout the Operating System. It's much, much more flexible than a bunch of folders in the Finder. You can keyword your pics, populate Smart Albums automatically, rate and edit your pics, all via iPhoto.
    You can find out more here:
    http://www.apple.com/ilife/iphoto/
    there are some tutorials here
    http://www.apple.com/ilife/tutorials/#iphoto
    and a good forum here:
    http://discussions.apple.com/category.jspa?categoryID=143
    My best advice is to explore the app by dragging in maybe 100 pics and testing things out, gettting the hang of it. It's miles better than a folder hierarchy.
    Regards
    TD

  • I was re-naming a folder with many sub folders suddenly Thunderbird did not respond and the folder and sub folders I was re-naming disappeared.

    I was re-naming a folder with many sub folders attached, suddenly, Thunderbird did not respond and the folder I was re-naming disappeared along with all the sub folders attached to it. How can I get them back? I am not a computer savvy person. Any help would be greatly appreciated.
    Thank you.
    [email protected]

    Turned out that my anti-virus was doing a scheduled scan and had found a virus in an email attachment in my deleted items folder, thus nothing being able to do during the scan.

  • No longer able to add folders to iCloud -- only sub-folders

    I just tried to add a new folder to my iCloud account (web interface) for the first time in ages...
    Everytime I click on the + it wants to create a sub-folder for some already existing folder.
    DId something else change with this switch to @iCloud.com change?
    10.8.2 / Safari 6.0.2

    Duh never mind... forgot to unselect the existing folder.

  • How to monitor contents of sub-folders in a Folder Action?

    Hello. I am wondering how I might read a folder's contentModDate within Terminal, i.e. from the command line and/or within a Folder Action.
    This is the situation: I am running Periscope Pro (PP) for motion-detected videos, which by default, places them within the user's ~/Movies/com.zipzapmac.Periscope-Pro folder. Within that folder, PP creates a folder with it's name based upon (a) machine name and (b) primary MAC address. For example, we'll pretend this folder is called MacPro(001122334455). Then within that folder, as PP is running in motion-detection mode, it creates a new folder based on the current date and then, within that, places videos when motion is detected. Very straight-forward and it works just fine.
    What I would like to do is have a folder action that (a) detects when any new folder or file is created within MacPro(001122334455) and (b) sends me a text-message via Apple Mail.
    If the MacPro(001122334455) folder is empty, I can create a Folder Action that will detect the creation of a sub-folder when the first motion-detected video is created and that successfully sends me a text-message, BUT if a second video is created later within the same date-named folder, I will not get a message. I would get a text-message on the following day as a new folder is created within MacPro(001122334455) that signals the first motion-detected video of the day, but again not subsequent videos on the same day.
    The text-message via Apple Mail I have easily scripted via Applescript and it works flawlessly.
    Since Folder Actions only work upon a single pre-defined folder and not on sub-folders, I can never get automatically notified via text-message of second/third/fourth/etc. motion-detected videos as they're created... only the first one of each day.
    So, I'm wondering whether there's a different way, perhaps through launchd that I might script this process. I'm thinking that if the contentModDate value of the MacPro(001122334455) folder could be read, compared with the last known value, and then---if different---execute the Applescript. OR PERHAPS I'm going about this all wrong and you might have another, better idea?
    I'm open to suggestions.
    -- David (da2357)

    Well, I found a solution that does not use a Folder Action. Since Folder Actions will only work upon the specified folder and not upon the contents of any sub-folders, I needed a different solution.
    First, I launched Terminal and created a new file called monitorPeriscope. I set executable permissions (chmod 700 monitorPeriscope). The contents of the file:
    #!/bin/bash
    # monitor the size of a specified folder and
    # when the size increases, run an applescript
    # copyright 2013, david dot allie at me dot com
    # you are welcome to use this script, but please attribute authorship.
    # CONSTANTS
    WATCHFOLDER="/users/xadmin/movies/com.zipzapmac.Periscope-Pro"
    SIZEFILEONE="/users/xadmin/.bin/foldersizeone"
    SIZEFILETWO="/users/xadmin/.bin/foldersizetwo"
    MYAPPLESCRIPT="/users/xadmin/documents/dropbox/programming/applescript/motion_de tected_text.scpt"
    # START
    # calculates current size of watchfolder, saves to sizefiletwo, then
    # performs a diff operation, result which is evaluated in if statement,
    # and if different, runs applescript, and copy sizefiletwo to sizefileone
    du -h -k -d3 -c $WATCHFOLDER | awk 'END{print}' | awk '{print $1}' > $SIZEFILETWO
    diff --brief $SIZEFILEONE $SIZEFILETWO
    if [ $? -eq 1 ]
      then
        osascript $MYAPPLESCRIPT
        cp -f $SIZEFILETWO $SIZEFILEONE
    fi
    exit 0
    Next, I created the following Applescript, replacing Some User, [email protected] and the text address of [email protected] below with my real values.
    using terms from application "Mail"
    tell application "Mail"
    set theName to "Some User"
    set theAddress to "[email protected]"
    set theContent to "Motion detected in OFFICE."
    set newMessage to make new outgoing message
    tell newMessage
    make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
    set visible to true
    set sender to "[email protected]"
    set subject to "ALERT "
    set content to theContent
    send newMessage
    end tell
    end tell
    end using terms from
    Next, using the touch command, I created /users/xadmin/.bin/foldersizetwo and /users/xadmin/.bin/foldersizetwo as needed for the bash shell script (touch /users/xadmin/.bin/foldersizeone and touch /users/xadmin/.bin/foldersizetwo).
    Next, still in Terminal, I navigated to ~/Library/LaunchAgents and created the following plist using nano, which I named com.xadmin.monitorPeriscope.plist:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
              <key>Disabled</key>
              <false/>
              <key>Label</key>
              <string>com.xadmin.monitorPeriscope</string>
              <key>ProgramArguments</key>
              <array>
              <string>/users/xadmin/.bin/monitorPeriscope</string>
              </array>
              <key>RunAtLoad</key>
              <true/>
              <key>StartInterval</key>
              <integer>900</integer>
    </dict>
    </plist>
    Finally, all that was needed was to log out and then log back in. Once I launched the Periscope Pro app and started the motion-detection mode, I left my office... and within fifteen minutes I received a text message indicating that motion had been detected in my office. In the plist above, I set a StartInterval of 900 seconds, which corresponds to 15 minutes. I can reduce it down to 300 seconds (5 minutes) without it adversely affecting performance, but I'm going to leave the setting where it is for now.
    So, I solved my own problem and I'm pleased with the results.
    -- David

  • Having trouble uploading sub folders to Sharepoint online using PowerShell

    Hi there,
    I have been attempting to upload folders and files to a document library on Sharepoint Online. I can upload the top-level folder and the files in that folder but when i comes to the sub folders i get this message: 
    New-Object : Exception calling ".ctor" with "2" argument(s): "Access to the path 
    'C:\FilePath\TestFolder\TestFolder1' is denied."
    At C:\FilePath\ImportFiles_Test1.ps1:54 char:29
    +               $FileStream = New-Object IO.FileStream($File.FullName,[System.IO.F ...
    +                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
        + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
    I'm running as an Administrator so I have full access to the folders
    here's my code so far
    #Specify tenant admin and site URL
    $User = "[email protected]"
    $SiteURL = "https://company.sharepoint.com/sites/TestSite"
    $Folder = "C:\Users\user\Documents\SharepointTestFolder"
    $DocLibName = "Admin"
    #Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
    $Password = Read-Host -Prompt "Please enter your password" -AsSecureString
    #Bind to site collection
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
    $Context.Credentials = $Creds
    #Retrieve list
    $List = $Context.Web.Lists.GetByTitle($DocLibName)
    $Context.Load($List)
    $Context.ExecuteQuery()
    Function ImportFiles()
    #Get name of folder
    $NewFolder = Split-Path $Folder -Leaf
    #upload folder to sharepoint
    $UploadFolder = $List.RootFolder.Folders.Add($NewFolder) #this may not upload folders within folders.
    $Context.Load($UploadFolder)
    $Context.ExecuteQuery()
    $FilesInFolder = Get-ChildItem $Folder | ? {$_.PsIsContainer -eq $False}
    #Loop Through Folder
    Foreach ($File in (dir $Folder))
    #If file
    If($File)
    #Upload file to Sharepoint
    $FileStream = New-Object IO.FileStream($File.FullName,[System.IO.FileMode]::Open)
    $FileCreationInfo = New-Object Microsoft.SharePoint.Client.FileCreationInformation
    $FileCreationInfo.Overwrite = $true
    $FileCreationInfo.ContentStream = $FileStream
    $FileCreationInfo.URL = $File
    $Upload = $UploadFolder.Files.Add($FileCreationInfo)
    $Context.Load($Upload)
    $Context.ExecuteQuery()
    Else
    recurse ImportFiles
    ImportFiles
    If anyone could help me I'd be so grateful!!
    Thanks!!
    Dearbhla Bradley

    The exception is pretty clear. for some reason the script is not able to open the folder TestFolder1 on the local hard drive.
    I noticed in the script you have specified the $Folder variable to be "C:\Users\user\Documents\SharepointTestFolder" while the exception is for "C:\FilePath\TestFolder\TestFolder1"
    Will you please help me understand this difference?
    Also, sorry I'm not familiar with the "recurse" calling method. I'm suspecting you're telling it to call the ImportFiles() function again, though if this is the case it looks to me that it's reusing the same $Folder variable that was defined at the start,
    rather than using the folder object you have just identified.
    Jason Warren
    @jaspnwarren
    jasonwarren.ca
    habaneroconsulting.com/Insights

  • Deleting all inherit sub-folders permission and reassigning to specific group

    Hi,
    i am trying to assign sub-folders level permission in sharepoint document library. Want to delete all previous inherit permission first and then assign  sub-folders permission to specific group. i am having problem with following code, cannot make a
    call to the function. Could you tell me what should i modify the code to work properly.
    Thanks in advanced
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    namespace ManageFolderLevelPermission
        class FolderLeverPermission
            static void Main(string[] args)
                //Connect to Sharepoint Site
                SPSite oSPSite = new SPSite("http://nyc01d1sp:8080/");
                //Open Sharepoint Site
                SPWeb web = oSPSite.OpenWeb("/hr/DI/");
                //Get the Sharepoint list item for giving permission
                foreach(SPFolder folder in web.GetFolder("http://nyc01d1sp:8080/hr/DI/docs/").SubFolders);
                setPermissions();
            private static void setPermissions(SPFolder folder,SPSite oSPSite, SPWeb web)
                SPGroupCollection spc = web.SiteGroups;
                //Break the role inheritance in order to assign individual rights on folders
                if (!folder.Item.HasUniqueRoleAssignments)
                    folder.Item.BreakRoleInheritance(true);
                while (folder.Item.RoleAssignments.Count > 0)
                    try
                        folder.Item.RoleAssignments.Remove(0);
                    catch (Exception)
                        break;
                //Role Assignment For the Current User
                SPUser CurrentUser = SPContext.Current.Web.CurrentUser;
                SPGroup group = spc["GroupName"];
                SPRoleAssignment roleAssignment = new SPRoleAssignment((SPPrincipal)CurrentUser);
                roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions.GetByType(SPRoleType.Administrator));
                folder.Item.RoleAssignments.Add(roleAssignment);
                //Role Assignment for the Group "Contentteam - Management"
                roleAssignment = new SPRoleAssignment((SPPrincipal)group);
                roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions.GetByType(SPRoleType.Administrator));
                folder.Item.RoleAssignments.Add(roleAssignment);            
                oSPSite.AllowUnsafeUpdates = true;
                folder.Item.Update();

    Hi Hemendra,
    Thanks for your reply. Actually i am trying to do two things here. First i am creating sub-folders using following code. And then trying to assign individual group permission on these sub-folders using following Powershell script. Now problem is when i am
    creating sub-folders, its also inheriting all the parent permission. Lets say i have customer folder name "Pepsi" and it has 4 sub-folders (like Account Management, Legal Drafts, Executed.. etc) . Now i want to assign individual group permission to each Sub-folder
    but root folder (Pepsi) should remain all the parent permissions. i did try to remove the permission first and then assigned permission to sub-folders. i was able to assign individual group permission to sub-folders but problem is, its also assigning Limited
    Access to the root folder. so basically i cannot see the folder as the root folder has limited access. Please let me know how can achieve that.
    using System;
    using System.Collections.Generic;
    using Microsoft.SharePoint;
    namespace Add_SubFolders
        class CreateFolders
            static void Main(string[] args)
                var foldersList=new List<string>();
                SPSecurity.RunWithElevatedPrivileges(delegate()
                    try
                        using (SPSite site = new SPSite("http://nyc01d1sp:8080/"))
                            using (SPWeb web = site.OpenWeb("/lel/DB/"))
                                web.AllowUnsafeUpdates = true;
                                    foreach (SPFolder folder in web.GetFolder("http://nyc01d1sp:8080/lel/DB/docs").SubFolders)
                                        if (folder.Url.ToString() != "/docs/Forms" && folder.Url.ToString() != "/docs/")
                                            foldersList.Add(folder.Url);
                                            SPFolder subFolder = web.GetFolder(folder.Url);
                                            Console.WriteLine("SubFolder is creating.....");
                                            subFolder.SubFolders.Add("Account Management");
                                            subFolder.SubFolders.Add("Legal Drafts");
                                            subFolder.SubFolders.Add("Executed");
                                            subFolder.SubFolders.Add("Sales");
                                        folder.Update();
                                        Console.WriteLine("SubFolder has been created");
                                    web.AllowUnsafeUpdates = false;
                    catch (Exception ex)
                        ex.Message.ToString();
      Power Shell Script to assign individual group to specific folders:
    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
      #$site = new-object Microsoft.SharePoint.SPSite("http://nyc01d1sp:8080/lel/DB/")
      #$site = Get-SPSite ("http://nyc01d1sp:8080/")
      $web= Get-SPWeb("http://nyc01d1sp:8080/")
      #$web = $site.OpenWeb()
      function GrantGroupPermission($groupName)
       [Microsoft.SharePoint.SPGroupCollection]$spgroups = $web.SiteGroups
       [Microsoft.SharePoint.SPGroup]$spgroup = $spgroups[$groupName]
       Write-Host $spgroup.Name -ForegroundColor Red
       $sproleass=new-object Microsoft.SharePoint.SPRoleAssignment([Microsoft.SharePoint.SPPrincipal]$spgroup)
       $folder.BreakRoleInheritance("true")
       $sproleass.RoleDefinitionBindings.Add($web.RoleDefinitions["Contribute"])
       $folder.RoleAssignments.Add($sproleass);
       Write-Host "Permission provided for group ", $groupName
      $doclib=[Microsoft.SharePoint.SPDocumentLibrary]$web.Lists["Shared Documents"]
      $foldercoll=$doclib.Folders;
      foreach($folder in $foldercoll)
       Write-Host $folder.Name
       if($folder.Name.Equals("Account Management"))
        GrantGroupPermission("Test Group")
       if($folder.Name.Equals("Executed"))
        GrantGroupPermission("Legal Group")
       if($folder.Name.Equals("Legal Drafts"))
        GrantGroupPermission("Legal Group")
       if($folder.Name.Equals("Sales"))
        GrantGroupPermission("Sales Group")
      Write-Host "Completed...."
      $web.Close()
      $web.Dispose()
      #$site.Dispose()

  • Pro grammatically create three sub-folders with specific name under each of root folders in site collection level??

    Hi,
    i have a document library Named "Digital" in a site collection. In that document library i have bunch of customer folders with different customer name. My requirement is i need to create three sub-folders (like Images, Processed, Status) each of
    customer folders. so how can i automate to create sub-folders with specific name. can i use object model or power shell to achieve this one.
    Thanks in advanced!

    Hi Murugesa,
    Thanks for your help. i was trying to create folder inside document library using your code. but unfortunately i cant debug code and cannot create folder inside customers folder. Following is the code, basically i am creating a SharePoint project and adding
    an item as class file and deploying to share point site and then trying to debugging code, but break-point showing as yellow circle. i checked solution has been deployed to the server but still not creating any folder. It will be very helpful if you can describe
    all the steps. should i create console application?
    Appreciated !!
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    namespace Add_Sub_Folders
        class Create_Folders
            public void Sub_Folders()
                var foldersList = new List<string>();
                SPSecurity.RunWithElevatedPrivileges(delegate()
                    try
                        using (var site = new SPSite(SPContext.Current.Site.Url.ToString()))
                            using (var web = site.OpenWeb())
                                web.AllowUnsafeUpdates = true;
                                foreach (SPFolder folder in web.GetFolder("http://nyc01d1sptmp01:8080/Shared%20Documents/").SubFolders)
                                    if (folder.Url.ToString() != "Shared Documents/Forms" && folder.Url.ToString() != "Shared Documents")
                                        foldersList.Add(folder.Url);
                                        SPFolder subFolder = web.GetFolder(folder.Url);
                                        subFolder.SubFolders.Add("Draft");
                                        subFolder.SubFolders.Add("Status");
                                        subFolder.SubFolders.Add("Final");
                                    folder.Update();
                                web.AllowUnsafeUpdates = false;
                    catch (Exception ex)
                        ex.Message.ToString();

  • Is there any way to have a smart mailbox search sub-folders

    My wife uses Mail.app for her business in which gets hundreds of emails a day and managing them all is quite a challenge. One important goal of e-mail management is archiving certain emails in folders (and sub-folders) without creating duplicates.  What I've done is to create rules to move e-mails into their respective the folders and flag them based varying criteria. This works great! 
    The problem is when I make a smart mailbox to include only flagged messages in a specific mailbox, only messages in the root mailbox are found.  All messages in the sub-folder are ignored or never considered. I used the "not in mailbox" option on my own mail.app but this isn't practical for her because she manages numerous e-mail accounts for clients and she adds new accounts frequently.  
    Is there a solution to my issue that doesn't involve puting all the messages into the root mailbox?

    Mine are showing emails in subfolders, but I don't have near that many emails.
    Maybe you need to reindex the spotlight database.
    The normal method is to add the Hard drive to the Privacy tab in Spotlight prefs. If that doesn't cause it to index, here is a Terminal way: http://www.maclife.com/article/howtos/how_reindex_spotlight

Maybe you are looking for

  • Adhoc Query report not working fine

    Hi, We have a customized infotype  9222 which stores the previous experience of the employees. Now I have created a adhoc query in which I have added this infotype.The problem which I am facing is when I put the Indian company codes and run the repor

  • Having Trouble Downloading After Effects VIA the Cloud.

    So I purchased Adobe AFter Effects through the cloud on a month to month basis. I had just finished the free trail and decied I needed to download it. I then dowloaded the free trail of Creative Cloud just to see how the layout was etc. Then I purcha

  • Stopping On Playback

    I have 10 Macs and i have installed Premiere CS6 on all of them. We have one issue, Once you have imported my video, i drop it on the time line and hit the space bar to play it. The video stops about a second after. I  hit the space bar again and it

  • WIP Accounting document anomaly

    I am doing a process order settlement using KO88.  After execution, system is showing an accounting document with etnries: Change in WIP Dr. & WIP A/c. Cr.  But the entries should be "Change in WIP Cr. & WIP A/c Dr.".  Why the above is happening with

  • Unable to restore iPhone 5S with iOS 8.2 (Error -1)

    Unable to restore iPhone 5S with iOS 8.2 (Error -1) I tried to install previous versions 8.0 and 7.0.3, it returns another error. I tried with iTunes 12.1.1.4 and 11.2 Even in DFU mode its giving the same error.