I have a script that can display the file path, there are some properties that can not be displayed, such as date modified, date create, owner.
@ECHO off
SET v1=%%~dpF
SET v2=%%~nxF
(for /r %%F in (*) do @echo "%v1%","%v2%"
pause
Example Output :
- D:/newfolder1/tester.doc | 18/02/2016 01:30:00 | 16/02/2016 02:13:12 | Nickolas
- D:/newfolder2/tester2.doc | 11/03/2016 01:30:00 | 12/02/2016 02:13:12 | Marx Timberlack
- D:/newfolder3/tester3.doc | 18/02/2016 01:30:00 | 16/02/2016 02:13:12 | Administrators
Basically I want to add a 4th parameter, which should show file owner. It is in Windows 7 environment.
As mentioned in a comment by Klitos Kyriacou, PowerShell can do this:
PARAM (
$Path = 'C:\Users\MarxHood\Desktop\', $Report = 'C:\Users\MarxHood\Output.csv'
)
$Owner = @{
Name = 'FileOwner'
Expression = { ((Get-Acl $_.FullName).Owner).Split('\')[1] }
}
Get-ChildItem -Path $Path -Recurse | Select FullName, LastWriteTime, CreationTime, $Owner | Export-Csv -NoTypeInformation -Delimiter "|" $Report
Just change the locations as necessary for $Path
and $Report
at the top.
Edit
Below is a method using a batch file, unfortunately this is dependent upon the localised date/time output; (tokens may need adjusting to suit your locale) . Domain names in the owner output string which contain a space would also cause this to fail.
@Echo Off
Set "Path=C:\Users\MarxHood\Desktop"
Set "Report=C:\Users\MarxHood\Output.csv"
(For /F "EOL= Tokens=1,2,4*" %%A In ('Dir/A-D/-C/Q/TC "%Path%\*"'
) Do For /F "Delims=" %%E In ("%%~tD"
) Do Echo="%%~fD"^|"%%E"^|"%%A %%B"^|"%%~nC")>"%Report%"
Remember to change the locations as necessary for %Path%
and %Report%
near the top.
Using the command dir /TC
will show you the creation date of each file. /TA
will show you last-access, and /TW
will show last-written.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.