Change file ownership of only admin-owned files

Posted on 2012-08-20
Last Modified: 2012-08-25
I want to find a way to change the ownership of entire folders and their contents to a specific user, but only change ownership where files and folders are currently owned by "BUILTIN\Administrators."  I don't want to change existing ownerships if some files within these folders are already owned by specific users.

Does anyone know of a way of accomplishing this?  

I am guessing that the ownership was set to administrators when file servers were changed, and certain file attributes were lost in the file transfer.
Question by:HomerTNachoCheese
    LVL 8

    Assisted Solution

    The only answer on this question i have is to use a third party tool like

    Here you can define filter rules to set the new acl´s
    LVL 6

    Author Comment

    Wilder - your solution may work, but I want to try something free first.  I was taking a look at subinacl.exe, but I am not sure if that would work.  Points should come your way after I collect more feedback from others :)

    I suppose a script that I would need to build, if there are no free utilities out there, would be a script that first outputs a list of folder contents that belong to the admin to a temp file.  Then, for each file run subinacl (or a similar executable) that sets the new owner.  If anyone has suggestions along those lines it would be appreciated.
    LVL 6

    Accepted Solution

    Let's say I want to run through the Q: drive to find all the admin-owned files and set ownership to HomerT:

    Step 1:
    FileList (
    Run the command filelist /owners /fullpath q: >owners.csv

    Step 2:
    Open the csv file in Excel, sort by owner, delete rows we will not be changing.
    Delete all columns except for Full Path (which will be column A).

    Step 3:
    For column B, set a formula based on column A.  So, if A1 was my first file name, then B1 would have this formula:
    =CONCATENATE("icacls """,A2,""" /setowner HomerT")
    I need to have double quotes around my file names, so """ is how I get a double quote to appear in the string.
    For every file listed, paste this formula.

    Step 5:
    Copy and paste column B into Notepad.  Entries should look similar to this after pasting:
    icacls "q:\Calibration Records\CALTOOLS\CF001.doc" /setowner HomerT
    icacls "q:\Calibration Records\CALTOOLS\CF002.doc" /setowner HomerT
    icacls "q:\Calibration Records\CALTOOLS\CF003.doc" /setowner HomerT
    icacls "q:\Calibration Records\CALTOOLS\CF005.doc" /setowner HomerT

    Step 6.
    Save as a batch file and run it.

    This assumes that you have icacls, which is in Windows 7.  Other operating systems may have other commands, or you may need to download some similar tool.  This process does not force ownership change, but it appears to work for me.
    LVL 6

    Author Closing Comment

    I think my solution is the best solution because of price (free).  It has many manual steps, but I can live with that.  I am sure there are ways to throw this whole process into a batch file, eliminating the Excel steps and Notepad steps completely.  

    Wilder - your solution appears it will work just as well, and probably be much more user-friendly at the same time, therefore, you get some points!

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now