Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

Powershell & windows batch: list who create a file

Hello experts,
I have multiple CSV files in a folder.
I am looking for a powershell or a Windows batch to list in a result.csv the file name in column a and the author (who create the file) of the file in column a.
Thank you in advance.
Avatar of Sam Jacobs
Sam Jacobs
Flag of United States of America image

$FilePath = "c:\files"
$OutputPath = "c:\output"
Get-ChildItem $FilePath | Select Name,@{Name="Author";Expression={(Get-ACL $_.Fullname).Owner}} | 
	Export-Csv $OutputPath\results.csv -NoTypeInformation

Open in new window

SOLUTION
Avatar of Michelangelo
Michelangelo
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Luis Diaz

ASKER

Thank you Bill, the problem of the owner is that csv files cames from zip files so if I unzip and transfer them I will appear as the owner.
I need to know the creator.
I tested your proposal but I got an owner.txt blank.
Here is my version:
setlocal EnableDelayedExpansion

set BaseDir=%Cd%
set OutFile=%BaseDir%"\owner.txt

(
    for /f "tokens=*" %%A in ('dir /q "%BaseDir%\*.csv" ^| findstr /b /r /c:"[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]"') do (
        set Line=%%~A
        echo.!Line:~62!,!Line:~39,23!
    )
)>"%OutFile%"
pause

Open in new window

For powershell approach possible to adjust variables to have get-location folder instead of reported folder?
Thank you.
Same result with powershell approach I got the author and not the person who create initiate the file.
Zip archives do not save extended properties as far as i know. Are you able to see original creator via Windows Explorer?
Avatar of Bill Prew
Bill Prew

Csv files to check are in a zip file when I unzip I checked properties and it is mentioned that the author is me.
Yes, that is because you were the one that extracted the files to the Windows directory, at which time it assigned you as the owner in the directory owner info.

But that information is not stored in a ZIP file when files are added to the ZIP, so there is no way to preserver the original owner of the files that went into the ZIP when you unzip them.


»bp
Exactly. Zip archives do not save extended properties.
Noted. Thank you very much for your help.