Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

asked on

How can I get a list of all files of a network drive sorted by date created/modified?

Hi Experts,

I'm looking to see which files were placed today (or last few days) on a network drive, since they can be in different folders/sub folders, how can I get such a list?

PS. If I can see which user created them that would be great..
Avatar of NVIT
NVIT
Flag of United States of America image

Today...
FORFILES /M z:\folder\*.* /S /D +0

Open in new window


Since 4/8/2017 till today...
FORFILES /M z:\folder\*.* /S /D +4/8/2017

Open in new window

Avatar of bfuchs

ASKER

Hi,

I get no files found which does not makes sense as I myself downloaded some..

Thanks,
Ben
Avatar of Bill Prew
Bill Prew

Try this syntax.

FORFILES /P z:\folder /M *.* /S /D +0

FORFILES /P z:\folder /M *.* /S /D +4/8/2017



»bp
And to see the full path of the files found do:

FORFILES /P z:\folder /M *.* /S /D +0 /c "cmd /c echo @path"

FORFILES /P z:\folder /M *.* /S /D +4/8/2017 /c "cmd /c echo @path"



»bp
Avatar of bfuchs

ASKER

@Bill,

1-Yours includes files updated as well, I'm only interested in files created today.
2- Would prefer to see network user name
3- If possible to include file size as well.

PS.Reason for these, someone is inserting huge files on the network and we must stop it ASAP!

Thanks,
Ben
Avatar of bfuchs

ASKER

Who can help me here?!

Thanks,
Ben
SOLUTION
Avatar of NVIT
NVIT
Flag of United States of America 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
Avatar of bfuchs

ASKER

Hi,

See attached.

1- What does it mean size variable?
2- Which Date range I enter to see last two days?
3- Where is the file being saved?
4- Will this only include files created?

Thanks,
Ben
Untitled.png
1. Sizes 1 MB and greater
2.
$oldest = Get-Date '5/1/17'
$newest = Get-Date '5/3/17'

Open in new window

3. Where you run the code. c:\users\bfuchs You can change that if you like. e.g. "c:\folder\bigfiles.csv"
4. Files meeting that date range and file size.
Avatar of bfuchs

ASKER

Where you run the code. c:\users\bfuchs..
This is where I looked for and nothing there..
4. Files meeting that date range
My question is if this will not include files updated that date range?
As mentioned, the main purpose is to find who is creating large files on the server, while if they just update that's fine.

Thanks,
Ben
Avatar of bfuchs

ASKER

OK, now after I pressed enter it did create a csv file, however file is empty.

Also I'm having a problem copying from clipboard into PowerSheel prompt.
Just saw other ppl are having this issue as well..
https://social.technet.microsoft.com/Forums/office/en-US/8dcf6714-bffc-4199-95e3-bae1cf6dd838/issue-with-pasting-to-command-linepowershell?forum=winserverpowershell

Thanks,
Ben
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
> My question is if this will not include files updated that date range?.

I'm not able to test this right now. My guess is it includes files with the modified or created date , i.e. The date you see associated with the file.

> ..., while if they just update that's fine.
I assume you do want to include these also?

I've tested and the code before posting. It works fine here.

Maybe if you post your code I can help you if there's an error in it.
Correction/clarification to my prior post 42119660


> 2- Which Date range I enter to see last two days?
Assuming you want today's 5/4/17 and yesterday's 5/3/17 files.
$oldest = Get-Date '5/3/17'
$newest = Get-Date '5/5/17'

Open in new window

Avatar of bfuchs

ASKER

@Bill,

Will try download that software & let you know.

@NVIT,

This is what I was trying and created an empty file
$size = 1MB
$Path1 = "F:\*.*"
$oldest = Get-Date '5/1/17'
$newest = Get-Date '5/4/17'
Get-ChildItem $Path1 -Recurse |
  Where-Object {$_.LastWriteTime -gt $oldest -AND $_.LastWriteTime -lt $newest -and $_.Length -gt $size} |
  Select FullName, LastWriteTime, Length, @{n="Owner";e={(Get-Acl $_.FullName).Owner}} |
  Export-CSV -notypeinformation "bigfiles.csv"

Open in new window

However at the moment I cant even use the copy/paste feature there in PowerShell, when I right click nothing shows up..

Thanks,
Ben
bfuchs... Your code worked fine here. It finds files dated 5/3/17 and 5/2/17.

> I cant even use the copy/paste feature there in PowerShell
Alternatively, does using Ctrl-C (copy) and Ctrl-V (paste) work?

You can also user the powershell ISE instead of the console. There, you can open powershell files (.ps1), edit, and run them.
Avatar of bfuchs

ASKER

Your code worked fine here. It finds files dated..
Did you tested with sub folders?
See attached empty file that got created.


Alternatively, does using Ctrl-C (copy) and Ctrl-V (paste) work?
I see when first open powershell and right click it does work.

You can also user the powershell ISE
How do I open that?

Thanks,
Ben
bigfiles.csv
Did you tested with sub folders?
Yes. Make sure you get the $oldest and $newest dates correct. For today's files, you need 1 day ahead, i.e. 5/5/17

On Windows Start button, type ISE. "Windows PowerShell ISE" shows in the results.
Avatar of bfuchs

ASKER

OK, on the ISE I get the following error msg
The string starting:
At line:8 char:33
+   Export-CSV -notypeinformation  <<<< "bigfiles.csv
is missing the terminator: ".
At line:8 char:46

Thanks,
Ben
You're missing the ending quote after csv

 Export-CSV -notypeinformation  <<<< "bigfiles.csv"
Avatar of bfuchs

ASKER

Ok, now I'm finally starting to understand whats going on..

1- The file I created for testing was less then 1 MB.
2- This does not work for sub folders.
3- All files are comimg up as owner BUILTIN\Administrators, regardless which pc creates it.

PS. My main issue is #2, lets see if this can get solved.

THanks,
Ben
It does work for sub folders. At least here it does. Maybe another expert can chime in and test it.
Avatar of bfuchs

ASKER

Well this is how I tested,

Copied a file 1+MB and pasted in F drive, then ran the script and saw that file listed.
Then copied and pasted again that file in a sub folder (F:\Conversion), ran the script and didnt list that file, only the first.
Then renamed that file, copied and pasted under F:, ran the script and then saw 2 files.

Perhaps you have other explanation why it did that..?

Thanks,
Ben
Avatar of bfuchs

ASKER

The SearchMyFiles utility so far came the closest to meet my needs..
Thank you experts!