topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday April 25, 2024, 2:05 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Script that would list the file name and its owner of a file inside each folder  (Read 4662 times)

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
I tried searching for this and did run across a few answers that would work in Linux using Sodu but unfortunately I need the same option for Windows. 
At the office, there is a Network folder that is used for special purposes and it contains about 200 subfolders with each of them containing a single file.  I am trying to solve a riddle that would require knowing the owners of the single file stored in each subfolder.  There are two possible owners for the files.  The answer to that question might tell me if the reason for a recent problem what i think it is, or not.
What I need is a list showing each subfolder on the network drive along with the name of the owner(s) of the single file inside each subfolder.  The single file in those folders has the same name so the list has to show the name of the each subfolder or I wont be able to tell them apart.
I was doing this manually and realized there had to be a better way :)  And I knew exactly where to look for an answer :) 
Thanks for pointers

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
There used to be packages of Linux commands compiled for Windows.  Maybe they have been discarded since I cannot find them for download.  But if you know how to do it using sudo I would try to find a sudo that runs on Windows.  I have never tried this myself but it may be worth a look.

Also it may be that Windows 11 has some linux support so the recompiled Linux apps may not be needed now.

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,924
    • View Profile
    • Donate to Member
I tried searching for this and did run across a few answers that would work in Linux using Sodu but unfortunately I need the same option for Windows. 
At the office, there is a Network folder that is used for special purposes and it contains about 200 subfolders with each of them containing a single file.  I am trying to solve a riddle that would require knowing the owners of the single file stored in each subfolder.  There are two possible owners for the files.  The answer to that question might tell me if the reason for a recent problem what i think it is, or not.
What I need is a list showing each subfolder on the network drive along with the name of the owner(s) of the single file inside each subfolder.  The single file in those folders has the same name so the list has to show the name of the each subfolder or I wont be able to tell them apart.
I was doing this manually and realized there had to be a better way :)  And I knew exactly where to look for an answer :) 
Thanks for pointers



Two questions. Does the ownership of files need to remain as it is? Or is there a need to reduce the amount of file/folder owners to just one?
If the ownership needs to be reduced to just one, just use a freeware tool called:  SetACL Studio
Well, the software is not really freeware, the maker of the software used to license it, but nowadays he gives you a registration code with your download.

It looks simple and does its task much better than what NTFS itself does. This software disregards any pre-configured settings/policies and changes ownership of files and folders to what you want. This disregard may not 'float your boat', but it has helped me out in the past. I only install it when I need it and remove it when it is not needed anymore, preventing any misuse. As is always, with power comes responsibility and this software might be regarded as basic, but do not kid yourself, it is powerful.   

Lets just say that as long as I manage Windows systems that work with NTFS, SetACL Studio will be part of my software-toolkit.

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Does (at a command prompt, not Powershell) "dir /s /q" not do what you need?
vi vi vi - editor of the beast

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
X16WDA:  Thanks!
I always forget the easy ways.  :huh:   Your setup does work.  For some reason, i cant seem to get it to progress through all folders before getting stuck.  Probably due to the folders being on a network resource.  If i can get it to go through each folder in the directory and add the one filename and its ower to the text file it would be perfect... I tried using tthis and it works as long as i am inside the folder that holds the file.  But for some reason, when i start in the main directory and add the /s  as ..  (dir *.* /s/q >c:\lists\owner.txt )  so that it steps through all the subdirectories and puts the owners.txt into a local folder where I have write permission , it seems to get stuck.  Using the /q switch does give the owner info i needed ,  Now if i can just get the command to iterate through all 200 subdirectories....

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Hm, when I run it without the *.* it enumerates all the subfolders on a network resource, this was on a 2008r2 box against a share on 2012r2. "dir /s /q \\servername\sharename"
vi vi vi - editor of the beast

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
i might not be waiting long enough  This mapped resource is known to be Very Slow.  WHen i watch the file.txt being created it stays at 0KB even after 5 minutes.  But the one i did earlier, i got tired of waiting and opened it while apparently it was still running.  That file now shows 35kb. 
This one finally finished at 42kb and I noticed it is only showing data for the first subdirectory and the folders in it.  There should be several more.  I need to try running this with some limiters such as dir B* or C* specified.,  All it gets now is the A* folders and subfolders.
Sigh :huh:  was supposed toi be a holiday weekend  :*(    :mad:

ANYWAY  Thanks 100% for the tip!  the process works .  I just need to be patient. :up:
« Last Edit: June 30, 2023, 09:46 PM by questorfla »