Reputation: 21
Please help me with command to list the files modified today.
I have tried the dir /TW
command but it lists all the files in the directory.
All the files listed for the dir /TW
command:
Upvotes: 2
Views: 4519
Reputation: 41952
You can use PowerShell
$ Get-ChildItem | Where-Object { $_.LastWriteTime -gt (Get-Date).Date }
# Or
$ ls | where { $_.LastWriteTime -gt (date).Date }
It can be called from cmd like this
$ powershell -C "ls | where { $_.LastWriteTime -gt (date).Date }"
$ powershell -NoProfile -ExecutionPolicy Bypass -NoLogo -NonInteractive -Command "Get-ChildItem | Where-Object { $_.LastWriteTime -gt (Get-Date).Date }"
You can add -Recurse
/-s
to Get-ChildItem
/ls
/gci
to list also items in subdirectories. Or add -File
/-af
to list only files
Upvotes: 0
Reputation: 17555
Using forfiles
, you can do the following:
FORFILES /S /D +14/03/2022 /M *.txt /C "cmd /c echo @path"
In order to know today's date, you can use DATE /T
.
You put it's result in a variable and use this in the forfiles
command.
For your information:
/S
: also investigate subdirectories/D <date>
: show files, modified later than that timestamp/M *.txt
: filter on extension/C "cmd /c echo @path"
: the /C
gives you the opportunity to launch a command (like echo
, cp
, del
, ...), the @path
is a forfiles
parameter, containing the full path of the found file.Upvotes: 1
Reputation: 1
Use
forfiles /d +[today's date, formatted as yyyy/mm/dd]
This result will show only the files modified today in the current directory
Also, the result will only list the file names
To see the full path, use:
forfiles /d +[yyyy/mm/dd] /c "cmd /c echo @path"
See forfiles /? for more info.
Upvotes: 0