[SOLVED] Auto-sort files in folders

Came across the "Magic Folder" plasmoid on a friend's KDE setup and liked the idea very much, especially for my downloads folder (I tend to download many things and then go through them later to sort away).
I found the "Download Sort" plugin for Firefox, but it doesn't always work and doesn't seem to be maintained anymore (last release 2006).
I also found this shell script on the Ubuntu forums, but it doesn't do what I want.
Does anyone know of a way (or a ready made program) that could do the following:
- Check every file that is placed in folder "X" (eg ~/downloads) [not only by Firefox, but always] and automatically distribute them to another folder by mime type or file extension
- This is not a must, but a nice and useful feature: automatically create subfolders by date for certain file types (useful for PDFs etc., but not needed for videos or music)
Thanks in advance
Last edited by JackH79 (2012-05-06 14:15:14)

I don't know about a ready program, but you can write a simple bash script to do that.
(I think this is very simalar to your ubuntu link, I can't view it).
#!/bin/bash
while read filename; do
echo -n "$filename "
case $(file -b --mime-type "$filename") in
image/png)
echo "is a png image"
mv -n "$filename" /somewhere/png/
image/*)
echo "is an image"
mv -n "$filename" /somewhere/otherimages/
application/pdf)
echo "is a pdf"
destdir="/somewhere/pdf/$(date +%Y.%m.%d)"
if [[ -d "$destdir" ]] || mkdir -p "$destdir"; then
mv -n "$filename" "$destdir/"
fi
echo "has mime $(file -b --mime-type "$filename"). I don't know what to do"
esac
done < <( find /path/to/magic/folder -type f )

Similar Messages

  • How to sort files and folders like Windows

    I don't know if this is specific to Arch or every other Linux distro but one thing that really bugs me in Arch is how files and folders are sorted. I use Windows as my main OS (don't start on that please) and I have one folder properly organized exactly as I want it and I like it how Windows sorts this. I access that same folder from my Arch installation, the problem is that the sorting is different and it gets on my nerves lol...
    This is how Windows sorts that specific folder:
    C:\Users\Nazgulled\Documents\University>dir /O
    Volume in drive C is Vista
    Volume Serial Number is F84E-02BE
    Directory of C:\Users\Nazgulled\Documents\University
    05-08-2009 15:34 <DIR> .
    05-08-2009 15:34 <DIR> ..
    05-08-2009 11:10 <DIR> [Archives]
    05-08-2009 14:38 <DIR> [Developers]
    05-08-2009 11:17 <DIR> [X] 1) Cálculo II
    05-08-2009 11:18 <DIR> [X] 2) Análise de Custos
    05-08-2009 11:18 <DIR> [X] 2) Cálculo de Programas
    05-08-2009 11:18 <DIR> [X] 2) Laboratórios de Informática III
    05-08-2009 11:18 <DIR> 2) Algoritmos e Complexidade
    05-08-2009 11:18 <DIR> 2) Arquitectura de Computadores
    05-08-2009 11:18 <DIR> 2) Comunicaçao de Dados
    05-08-2009 11:18 <DIR> 2) Engenharia Económica
    05-08-2009 11:18 <DIR> 2) Estatística Aplicada
    0 File(s) 0 bytes
    13 Dir(s) 24.700.485.632 bytes free
    And this is how Arch does it:
    nazgulled ~/University $ ls -l
    total 7
    drwxr-xr-x 1 nazgulled nazgulled 4096 2009-08-05 11:18 2) Algoritmos e Complexidade
    drwxr-xr-x 1 nazgulled nazgulled 4096 2009-08-05 11:18 2) Arquitectura de Computadores
    drwxr-xr-x 1 nazgulled nazgulled 4096 2009-08-05 11:18 2) Comunicação de Dados
    drwxr-xr-x 1 nazgulled nazgulled 4096 2009-08-05 11:18 2) Engenharia Económica
    drwxr-xr-x 1 nazgulled nazgulled 8192 2009-08-05 11:18 2) Estatística Aplicada
    drwxr-xr-x 1 nazgulled nazgulled 4096 2009-08-05 11:10 [Archives]
    drwxr-xr-x 1 nazgulled nazgulled 4096 2009-08-05 14:38 [Developers]
    drwxr-xr-x 1 nazgulled nazgulled 4096 2009-08-05 11:17 [X] 1) Cálculo II
    drwxr-xr-x 1 nazgulled nazgulled 12288 2009-08-05 11:18 [X] 2) Análise de Custos
    drwxr-xr-x 1 nazgulled nazgulled 4096 2009-08-05 11:18 [X] 2) Cálculo de Programas
    drwxr-xr-x 1 nazgulled nazgulled 4096 2009-08-05 11:18 [X] 2) Laboratórios de Informática III
    How can I get Arch/Linux to sort exactly the same as Windows?
    Last edited by Nazgulled (2009-08-05 14:41:47)

    toad wrote:
    Nazgulled wrote:Surely there must be a way to have the same sorting collation in Linux like in Windows
    Ah, no. The way they are doing it is nonsensical and not good practice for a unix style system. Having said that, some solutions have already been offered in this thread.
    While you are free to continue to ask others to help you achieve your aims, it may be more convenient for you to adapt to a structure that is displayed the same way under all systems (just to avoid frustration - not saying you _should_ do it ).
    I really don't care if it's nonsensical, I use Windows 95% of the time or more, it's my main OS, I'm used to it and I like it. Why should I care if it's not a good practice for a unix style system? I just want things to behave the way I like and for a free system like Linux where it doesn't even compare to Windows in terms of freedom in what I can do with it and configure the way I like, it sure is hard to change the way folders/files are sorted...
    It sucks that there isn't a proper solution but I'm not going to adapt anything, that would be nonsensical... But if I have to, I can live with the fact that there isn't a good solution and leave it as it is
    Thanks everyone for their input, "topic closed".

  • Sort files in folders

    Hey guys can anyone tell me how I can sort my files within folders in a specific order???  Not in alphabetical order, size, date, kind etc...but in an order that I want them in (documents from school to be exact, I would like to sort them in the progression of the lessons from week to week). I never knew how to do this at the time and now Im kind of learning how to sort all of my docs within Finder, but this seems to be the first stumbling block that I've come across???   Thanks :)

    electropop wrote:
    Thought about that but isn't there any other way?
    Not when the view for the folder is set to anything other than Icon view.
    In Icon view you can choose "none" for both Arrange By and Sort By (in View Options for that folder). This allows you to place the items in any sequence you wish.
    However, when the view is set to List, Column, or Cover Flow, although Arrange By can be set to "None", Sort By must be set to some criterium; by default it is set to "Name".
    So, if you're viewing the content in List view, items will be sorted by name (unless you change the Sort By criterium).
    You can add a number at the beginning to force a sort into the sequence you prefer, as has been suggested. Note that if you do this, add a leading 0 to single-digit numbers (like 01, 06, etc.); otherwise "10" and "11" will be sorted between "1" and "2".
    For similar things I use a quick date prefix (or, if the base name is the same, a date suffix) to force a sort into my logical groupings. To keep a logical assortment over time, I use the date form of YY/MM/DD so that items from different years don't get mixed together.

  • Arrange Sort Files and Folders in CC Website

    Does anyone know how to arrange and/or sort files and collections in the Creative Cloud website?  I uploaded files, and they are currently listed there in the order they were updated.  I would like to sort them alphabetically with collections first then files.  How can I do this?  Thanks.

    Currently there is no functionality like you describe, but I agree that this would be really helpful.
    I created an idea/feature request for the functionality here, please add your vote and comments
    http://forums.adobe.com/ideas/1575
    Thanks,
    -Dave

  • [SOLVED] nzbperl - sorting files by subject

    Hi
    I need some perl guru to help me out with changing the sort function in nzbperl (http://noisybox.net/computers/nzbperl/nzbperl.pl)
    sub sortFilesBySubject {
    my $quiet = shift;
    my @fileset = @_;
    if(!$nosort){
    porlp("Sorting files by filename (subject)...", $quiet);
    @fileset =
    sort {
    $a->{'name'} cmp $b->{'name'};
    } @fileset;
    porlp("finished.\n", $quiet);
    return @fileset;
    It sorts like this:
    r00
    r01
    r02
    rar
    I'd like to sort like so:
    rar
    r00
    r01
    r02
    Thanks for any advice :-)
    Last edited by valvet (2010-11-08 14:51:00)

    The debug is as follow ('ve changed the real filename as I'm unsure the rules regarding such info here):
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[1/1] - "filename.nzb" yEnc (1/1)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[01/23] - "filename.nfo" yEnc (1/1)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[02/23] - "filename.par2" yEnc (1/1)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[03/23] - "filename.r00" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[04/23] - "filename.r01" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[05/23] - "filename.r02" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[06/23] - "filename.r03" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[07/23] - "filename" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[08/23] - "filename.r05" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[09/23] - "filename.r06" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[10/23] - "filename.r07" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[11/23] - "filename.r08" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[12/23] - "filename.r09" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[13/23] - "filename.r10" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[14/23] - "filename.r11" yEnc (1/6)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[15/23] - "filename.rar" yEnc (1/40)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[16/23] - "filename.sfv" yEnc (1/1)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[17/23] - "filename.srr" yEnc (1/1)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[18/23] - "filename.vol00+01.par2" yEnc (1/3)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[19/23] - "filename.vol01+02.par2" yEnc (1/5)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[20/23] - "filename.vol03+04.par2" yEnc (1/9)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[21/23] - "filename.vol07+08.par2" yEnc (1/17)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[22/23] - "filename.vol15+16.par2" yEnc (1/33)
    [-]-[FULL]-[#something@EFNet]-[ subject_here ]-[23/23] - "filename.vol31+06.par2" yEnc (1/13)
    Thanks again for taking the time to help with this.

  • Can't sort files and folders

    Two questions:
    1. In a folder I want to sort the items in order allways folders first and second files by namne but sometimes the folders last. Is it any way to solve this? The Mac mixed sorting makes me mad.
    2. When in Finder-menu View the choice Clean Up and Arrange by is grey and can't be used. How come? Is it possible to make these choices active?
    Svante

    It's always frustrating when the designers didn't think to do it 'your' way. But we all figured out how to drive cars that were built 'their' way and we can do this too. The fact that MicroSoft did it another way, just is not relevant to working with your Mac. We're still coping with sillyunderscoresover here, and now our apps quit on us when we close their windows.
    You like a hierarchy that puts folders before individual file items: Make a folder, call it "Directories" (or even better " Directories", or "•Folders"), put all your folders in that window into it, and if you want, make a companion "Documents" folder for everything else. Click the flippy triangles of both to reveal their contents. There, everything in list order, folders first. You will have to do a teensy bit of handfiling you're not used to, but as others mentioned a simple naming convention would have spared you that (and this suggestion). If you truly hate the look, you can make invisible custom icons for the two folders and use a style like:"••••••Folders•••••", "-----Files----" so they look like headers.
    People have complained about missing this Windows 'feature' before without ever convincing me of its virtue. I can see which items are folders and don't need them artificially at the top (Sort by kind does that if ever I do) and find the integrated alphanumeric list useful for grouping unfiled documents near their folders. When I want the first item(s) on the list to be a folder, I so name it. You can cope, just like you can learn to navigate a new subdivision with all the cul-de-sacs. Now if I could just get used to this silly idea North Americans have that we should drive on the right.
    Message was edited by: Ed Hanna
    Message was edited by: Ed Hanna

  • Can't sort files and folders. Sorry doubble mailed

    Two questions:
    1. In a folder I want to sort the items in order allways folders first and second files by namne but sometimes the folders last. Is it any way to solve this? The Mac mixed sorting makes me mad.
    2. When in Finder-menu View the choice Clean Up and Arrange by is grey and can't be used. How come? Is it possible to make these choices active?
    Svante
    Message was edited by: Svante

    It's always frustrating when the designers didn't think to do it 'your' way. But we all figured out how to drive cars that were built 'their' way and we can do this too. The fact that MicroSoft did it another way, just is not relevant to working with your Mac. We're still coping with sillyunderscoresover here, and now our apps quit on us when we close their windows.
    You like a hierarchy that puts folders before individual file items: Make a folder, call it "Directories" (or even better " Directories", or "•Folders"), put all your folders in that window into it, and if you want, make a companion "Documents" folder for everything else. Click the flippy triangles of both to reveal their contents. There, everything in list order, folders first. You will have to do a teensy bit of handfiling you're not used to, but as others mentioned a simple naming convention would have spared you that (and this suggestion). If you truly hate the look, you can make invisible custom icons for the two folders and use a style like:"••••••Folders•••••", "-----Files----" so they look like headers.
    People have complained about missing this Windows 'feature' before without ever convincing me of its virtue. I can see which items are folders and don't need them artificially at the top (Sort by kind does that if ever I do) and find the integrated alphanumeric list useful for grouping unfiled documents near their folders. When I want the first item(s) on the list to be a folder, I so name it. You can cope, just like you can learn to navigate a new subdivision with all the cul-de-sacs. Now if I could just get used to this silly idea North Americans have that we should drive on the right.
    Message was edited by: Ed Hanna
    Message was edited by: Ed Hanna

  • How to view long file names and sort files within folders/projects?

    Hello, like so many people here, I am a new mac user, but certainly not computer illiterate. I have been a professional photographer for 10 years and recently change to mac and have been slowly trying to adapt my work flow accordingly.
    However I have become increasingly frustrated with Aperture 3 and after reading posts here it looks like I am certainly not the only person. While in my case I am sure it is because of my inexperience with mac systems so any guidance or assistance is much appreciated.
    Hopefully my questions are simple. I have been importing my images and re-naming images as I do so. A very simple combination of date, custom name, and counter. However, when I look at the images once the import has completed, they are not in any logical order within the 'project'. I have tried to sort them by file name, orientation, file size, etc, both ascending and descending, but they will not list in the correct order. eg the file '2010-03-09 Lyon France 001', continually falls between '2010-03-09 Lyon France 022' and '....021'.
    This has also lead me to a further question. While my file names can generally be read when the image is a landscape format, on the portrait images the file name it too long for me to read the whole name, and I can not find anyway to read the file name, eg browser, split screen, viewer, or full screen.
    Im sorry for all the details, and I am sure it is just my lack of experience, so appreciate your help.
    PS. On a separate note, I notice on another thread from the frustrated user 'ultratechy' that he got a reply from Tony who stated 'Also after installing any application you should always run disk utility and repair permissions....' Now as I am completely new to mac, I had no idea about this. Any other tips that I should always be aware of? Thanks again.

    Thanks for your reply Calx. If it makes you feel better, I am actually a New South Welshman - just living in the sunshine state!
    You are correct, I am trying to get my head around a new way of working and thinking, but I suppose it will all become clearer as time goes by. I have re-visited the manual many times, and been doing loads of research online, but just trying to put it all into practice now, so any tips or advice is always appreciated.
    At the moment, I am just working with a small part of my library until I do get my head around things before moving onto the bulk of my images. I have my images stored and backed up on multiple external hard drives. I am trying to import my images into aperture from an external drive as I have been slack over the years with keywording, metadata, organising, etc etc, so I figure from what I have read that aperture may assist me with making these time consuming tasks a bit quicker and easier.
    I have put a bit of thought into my filing structure, but I am sure that with further use and understanding, this may change in the future, but I hope not. To give you an example of how I am thinking and working - I have used folders for my regular clients, eg, Ray White, and then made another level of folders within 'Ray White' for the date, and then in each 'date folder' I place my projects and name them with the address of the property I have photographed. I select and edit images from each project and place them in albums under each project. Not sure if this is the most perfect structure, but any advice is welcome.
    Keywords is always an issue with me. Over the years I have compiled a number of list for each client and each 'type' of photography. For example, real estate images have there own list, I just simply manually add keywords for specific jobs, eg the address and any specific location or features.
    Again, advice and guidance always welcome and I would appreciate how you go about these topics? And maybe you can help explain something that I have pre-emted may be a problem, and it may happen when I move onto my larger library, and I am not sure how to explain this as it may show my lack of management previously. When I worked on my PC, I used PS4, Adobe Bridge and Camera RAW pretty much exclusively. For my landscape images for example, I might have 2 or 3 variations of the one images, eg, black and white, sepia, and color for instance. But the file name remained the same, I just stored them in different folders indicating what version of the image was stored there. Now I am thinking that when I import images in Aperture, I will come across difficulties because Aperture will think the I am importing duplicate images because I will in fact have 3 images with the same file name, even though the adjustments I have made to them are different. Is this the case? Will I have to make adjustments again? Will I have to change the name of the files prior to importing? If so, any advice or tips?
    Well, I should stop there. Im sorry to bombard you with some much text, but as mentioned, I am new, and finding my feet, so thanks for your time.

  • Auto-Sort Files in Bridge on Startup

    Is there a way to have Bridge automatically have files sorted by Filename? Currently every time I launch bridge (on startup of computer) it is set to sort manually. How do I make the default sort by Filename?  I have looked and cannot find a way. I am running Bridge CS5 on PC.

    I do have bridge to open on startup. I will attempt tp close before shutdown to see what happens then. Thanks for the input.
    As Curt states, the settings should be 'sticky' by default. Whenever you quit Bridge (either manual or during shut down system) it should start again with the latest used window and workspace. It also should not matter if you have start on login active are not. While this settings tends to be a bit buggy it should not effect the last used workspace setting.
    Maybe you can try a reset preferences for Bridge also, restart Bridge holding down option (Mac) or ctrl (Win) and from the menu choose reset preferences.
    If you create a custom workspace you can also include the default sort order and panel location to save to.

  • How can I sort all files and folders by size?

    Due to lack of space I need to find the biggest files and folders on my Mac OSX Mountain Lion, but "Size" is not in the Find options.
    And I don't know the wildcard to sort all files and folders by size in Easyfind.
    Thanks
    Sarah

    There are applications out there which are designed to show you files and the space they use.  Some of these applications and some strategies for making more room on your disk are given below.
    Freeing Up Hard Disk Space
    Freeing space on your Mac OS X startup disk
    Clearing Disk Space on Your Mac
    Seven ways to free up drive space

  • My macbook pro (using lion os) can't search files and folders on external hard drive! How can i solve it?

    When i used Snow leopard, i can search every files and folders on my external hard drive (NTFS). But when i upgraded to lion OS, sportlight didn't index files on exteranal hard drive and i can't search everything on external hard drive whatever i type in the search box! I also check the Finder preference and select when performing a search to "Search the current folder" ! How can i solve this problem! Please help me if you know!

    iTunes>Preferences (Cmd+,)>Advanced
    Choose the Ext HD (and the appropriate folder) as the location for your library.

  • Files dont sort correctly in folders

    After an archival re-intallation of OSX5.8, files dont sort correctly in folders; if I delete/paste a folder to an external hard-drive, they sort correctly. But when transferred back to the internal hard-drive in the same way, they once again sort incorrectly.
    I have no idea what the problem might be...its odd, isnt it?

    Details on what you mean by *incorrect sort*. In one place you discuss folders, in another, files.

  • Solved - How to take ownership and change permissions for blocked files and folders in Powershell

    Hello,
    I was trying to take ownership & fix permissions on Home Folder/My Documents structures, I ran into the common problem in PowerShell where Set-Acl & Get-Acl return access denied errors. The error occurs because the Administrators have been removed from
    file permissions and do not have ownership of the files,folders/directories. (Assuming all other permissions like SeTakeOwnershipPrivilege have been enabled.
    I was not able to find any information about someone successfully using native PS to resolve the issue.  As I was able to solve the issues surrounding Get-Acl & Set-Acl, I wanted to share the result for those still looking for an answer.
    Question: How do you use only Powershell take ownership and reset permissions for files or folders you do not have permissions or ownership of?
    Problem: 
    Using the default function calls to the object fail for a folder that the administrative account does not have permissions or file ownership. You get the following error for Get-Acl:
    PS C:\> Get-Acl -path F:\testpath\locked
    Get-Acl : Attempted to perform an unauthorized operation.
    + get-acl <<<< -path F:\testpath\locked
    + CategoryInfo : NotSpecified: (:) [Get-Acl], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetAclCommand
    If you create a new ACL and attempt to apply it using Set-Acl, you get:
    PS C:\> Set-Acl -path F:\testpath\locked -AclObject $DirAcl
    Set-Acl : Attempted to perform an unauthorized operation.
    At line:1 char:8
    + Set-Acl <<<< -path "F:\testpath\locked" -AclObject $DirAcl
    + CategoryInfo : PermissionDenied: (F:\testpath\locked:String) [Set-Acl], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetAclCommand
    Use of other functions like .GetAccessControl will result in a similar error: "Attempted to perform an unauthorized operation."
    How do you replace owner on all subcontainers and objects in Powershell with resorting to external applications like takeown, icacls, Windows Explorer GUI, etc.?
    Tony

    Hello,
    Last, here is the script I used to reset permissions on the "My Documents" tree structure that admins did not have access to:
    Example:  Powershell script to parse a directory of User-owned "My Document" redirection folders and reset permissions.
    #Script to Reset MyDocuments Folder permissions
    $domainName = ([ADSI]'').name
    Import-Module "PSCX" -ErrorAction Stop
    Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeRestorePrivilege", $true) #Necessary to set Owner Permissions
    Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeBackupPrivilege", $true) #Necessary to bypass Traverse Checking
    #Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeSecurityPrivilege", $true) #Optional if you want to manage auditing (SACL) on the objects
    Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeTakeOwnershipPrivilege", $true) #Necessary to override FilePermissions & take Ownership
    $Directorypath = "F:\Userpath" #locked user folders exist under here
    $LockedDirs = Get-ChildItem $Directorypath -force #get all of the locked directories.
    Foreach ($Locked in $LockedDirs) {
    Write-Host "Resetting Permissions for "$Locked.Fullname
    #######Take Ownership of the root directory
    $blankdirAcl = New-Object System.Security.AccessControl.DirectorySecurity
    $blankdirAcl.SetOwner([System.Security.Principal.NTAccount]'BUILTIN\Administrators')
    $Locked.SetAccessControl($blankdirAcl)
    ###################### Setup & apply correct folder permissions to the root user folder
    #Using recommendation from Ned Pyle's Ask Directory Services blog:
    #Automatic creation of user folders for home, roaming profile and redirected folders.
    $inherit = [system.security.accesscontrol.InheritanceFlags]"ContainerInherit, ObjectInherit"
    $propagation = [system.security.accesscontrol.PropagationFlags]"None"
    $fullrights = [System.Security.AccessControl.FileSystemRights]"FullControl"
    $allowrights = [System.Security.AccessControl.AccessControlType]"Allow"
    $DirACL = New-Object System.Security.AccessControl.DirectorySecurity
    #Administrators: Full Control
    $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Administrators",$fullrights, $inherit, $propagation, "Allow")))
    #System: Full Control
    $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("NT AUTHORITY\SYSTEM",$fullrights, $inherit, $propagation, "Allow")))
    #Creator Owner: Full Control
    $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("CREATOR OWNER",$fullrights, $inherit, $propagation, "Allow")))
    #Useraccount: Full Control (ideally I would error check the existance of the user account in AD)
    #$DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("$domainName\$Locked.name",$fullrights, $inherit, $propagation, "Allow")))
    $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("$domainName\$Locked",$fullrights, $inherit, $propagation, "Allow")))
    #Remove Inheritance from the root user folder
    $DirACL.SetAccessRuleProtection($True, $False) #SetAccessRuleProtection(block inheritance?, copy parent ACLs?)
    #Set permissions on User Directory
    Set-Acl -aclObject $DirACL -path $Locked.Fullname
    Write-Host "commencer" -NoNewLine
    ##############Restore admin access & then restore file/folder inheritance on all subitems
    #create a template ACL with inheritance re-enabled; this will be stamped on each subitem to re-establish the file structure with inherited ACLs only.
    #$NewOwner = New-Object System.Security.Principal.NTAccount("$domainName","$Locked.name") #ideally I would error check this.
    $NewOwner = New-Object System.Security.Principal.NTAccount("$domainName","$Locked") #ideally I would error check this.
    $subFileACL = New-Object System.Security.AccessControl.FileSecurity
    $subDirACL = New-Object System.Security.AccessControl.DirectorySecurity
    $subFileACL.SetOwner($NewOwner)
    $subDirACL.SetOwner($NewOwner)
    ######## Enable inheritance ($False) and not copy of parent ACLs ($False)
    $subFileACL.SetAccessRuleProtection($False, $False) #SetAccessRuleProtection(block inheritance?, copy parent ACLs?)
    $subDirACL.SetAccessRuleProtection($False, $False) #SetAccessRuleProtection(block inheritance?, copy parent ACLs?)
    #####loop through subitems
    $subdirs = Get-ChildItem -path $Locked.Fullname -force -recurse #force is necessary to get hidden files/folders
    foreach ($subitem in $subdirs) {
    #take ownership to insure ability to change permissions
    #Then set desired ACL
    if ($subitem.Attributes -match "Directory") {
    # New, blank Directory ACL with only Owner set
    $blankdirAcl = New-Object System.Security.AccessControl.DirectorySecurity
    $blankdirAcl.SetOwner([System.Security.Principal.NTAccount]'BUILTIN\Administrators')
    #Use SetAccessControl to reset Owner; Set-Acl will not work.
    $subitem.SetAccessControl($blankdirAcl)
    #At this point, Administrators have the ability to change the directory permissions
    Set-Acl -aclObject $subDirACL -path $subitem.Fullname -ErrorAction Stop
    } Else {
    # New, blank File ACL with only Owner set
    $blankfileAcl = New-Object System.Security.AccessControl.FileSecurity
    $blankfileAcl.SetOwner([System.Security.Principal.NTAccount]'BUILTIN\Administrators')
    #Use SetAccessControl to reset Owner; Set-Acl will not work.
    $subitem.SetAccessControl($blankfileAcl)
    #At this point, Administrators have the ability to change the file permissions
    Set-Acl -aclObject $subFileACL -path $subitem.Fullname -ErrorAction Stop
    Write-Host "." -NoNewline
    Write-Host "fin."
    Write-Host "Script Complete."
    I hope you find this useful.
    Thank you,
    Tony
    Final Thought: There are great non-PS tools like
    Set-Acl and takeown which are external to PS & can also do the job wonderfully.  It may be much simpler to call those tools than recreate the wheel in pure
    code.  Feel free to use whatever best suits your time, scope & cost.

  • HIDDEN files and folders

    What is the purpose of hiding files or folders in your applications or downloads folders??? This may seem to be a really dumb question but I would really appreciate some sort of understanding for hidings applications or downloads. Thanks
    Solved!
    Go to Solution.

    Hi there,
    This is useful to hide icons you don't want to see (e.g. icons that were pushed to your phone by your carrier but that you can't delete).  It can also be useful to hide certain applications that you don't want others to have easy access to.  For example, I have hidden the BlackBerry Protect icon to make it that much harder for someone to find and play with (or accidentally delete).  If I actually need to go into the app, I can simply unhide it while I need it, then re-hide it after.
    The big reason for doing this is that it simply makes it harder for someone to delete an app on your phone or to access an app on your phone that you don't want them to have access to.  And of course, it certainly helps that you can hide icons that are pushed from your carrier.
    I hope this is the info you're looking for, but if you meant something else, let us know!
    If you want to thank someone for their comment, do so by clicking the Thumbs Up icon.
    If your issue is resolved, don't forget to click the Solution button on the resolution!

  • How do I set up my iPad for outlook files and folders

    I want to see and use, on my iPad, the same files and folders I have in outlook on my PC. Also I want any changes I make on the PC or the iPad to sync with each other.
    PC is running Windows 7,
    Outlook version 2007, not the exchange version although I think I can get that by re-installing outlook and choosing that option.(I don't understand what exchange is but don't bother to explain it unless the solution requires using it)
    I currently use Gmail for my email accounts server. They are set up as POP accounts with Outlook using a .PST data file. However, IMAP is available for Gmail. My brief past experience with IMAP and .OST data files was kind of a disaster so it isn't my 1st choice for this.
    As I understand it using Outlook 365 with Microsoft's cloud and mobile app would solve my problem but I don't like clouds, 365 or IMAP (I may have to concede on some of those). If there is a way to do it through the Gmail accounts without any other cloud  that would be ideal since they already have all my email and I won't be spreading my personal info to other companies.
    I do have a Drop Box account but I currently only use it for some well vetted specific files that I share with specific individuals.
    I do not have any computer or network drive that is always on and might serve as a private cloud. That could be changed but then i'm relying there being no ISP or power interruptions which, of course do occasionally happen.
    Obviously I'm being rather picky here knowing that I'll probably have to live with some things less than ideal.
    I will consider 3rd party apps if they seem to be part of the solution.
    Thank you in advance for any person/s that want to help me on this.
    hsvt

    Thanks. I can change the forwarding settings in Gmail to be either POP or IMAP. That is quite simple. I just looked at those settings on the Gmail server and, to my surprise, both are enabled. In order for outlook client on my computer to receive IMAP emails I have to change the email account settings in my current outlook from POP to IMAP. I don't need to be using the Exchange version of Outlook to receive IMAP. I guess I'll do a little research tomorrow on Exchange so i can figure out what, if anything, it might do for me.
    I glanced at the link you sent me and it looks like it might be very helpful - another project for tomorrow.
    BTW: I hit "This Solved my Question" by accident. I meant only to "like' your response so you would get some benefit from the help you've given me so far. I hope I haven't discouraged others from taking a shot at helping me. I suspect there is more than one way to approach this and, as you know, my problem isn't really solved until I have what I need all set up and running smoothly.

Maybe you are looking for

  • Airport no longer connects to OPEN wireless networks

    Lots of people seem to think that their airport keeps dropping the connection to OPEN wireless networks because of the 2008-001 airport update. That is probably only true for a Macbook 2,1 (aka Macbook Core 2 Duo). I had the issue on my Macbook 1,1 (

  • I can't install itunes on my windows 7 (32 bit), I can't install itunes on my windows 7 (32 bit)

    I can't install itunes on my windows 7 (32 bit)... it keeps saying R6034 error and 1114 error. Help! PS: I used to have an older version of itunes and it worked fine until I tried upgrading it, Now it's totally messed up!

  • Start Windows in Mac OS X

    Is it possible to restart in windows from mac os x using boot camp? just like when you restart to mac os x while in windows.

  • Two gallery issues

    If someone uploads a video to your photo gallery it is not present or playable in atv2. If you change a photo (delete, or modify) in iphoto you can see that you have made a change by visiting the web; however, you will not be able to see this change

  • D-Link Ethernet Adapter DUB-E100 not recognized in Mountain Lion

    I just upgraded my MacBook Air to Mountain Lion (I know, but better late than never). Unfortunately, my D-Link USB Ethernet adapter (I have 2 of them) that worked fine on Lion is not recognized on ML. I've checked the D-Link site for updated drivers,