Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch File - List files modified within last 7 days

28 Aug 2012   #1
JDobbsy1987

Windows 8.1 Pro x64
 
 
Batch File - List files modified within last 7 days

Hi All,

I'm trying to create a batch file that will create a text file listing all the files within a folder that has been modified within the last 7 days, i thought this was going to be easy using some kind of switch that looks at the modified date but that doesn't seem to exist and i can't figure a way of doing it.

i have this script that will list files older than 7 days:
Code:
forfiles -p c:\ /s /m *.* /d -7 /c "cmd /c echo @file > c:\users\jdobbsy1987\desktop\list.txt"
and this cmd that will list all my files in in date order (newest first):
Code:
dir /s /o:-d
But can't seem to get anything to list files modified within the last 7 days.
It would need to look in subdirectories too.

Any help would be greatly appreciated.

Regards,
JDobbsy1987


My System SpecsSystem Spec
.
29 Aug 2012   #2
JDobbsy1987

Windows 8.1 Pro x64
 
 

Just wanted to let you know i have now managed to get this sorted although it was with a powershell script as opposed to a batch script.

This is the script i have used:
Code:
dir "c:\users\jdobbsy1987\" | ? {$_.PSIsContainer} | ? {$_.LastWriteTime -gt (Get-Date).AddDays(-7)} | ConvertTo-Html Name | Set-Content \\server\share\New_Media.htm
Although this code is slightly different than i originally wanted as this converts the output to a htm file rather than a text file but if you did want to output to a text file then this would be the script:
Code:
dir "c:\users\jdobbsy1987\" | ? {$_.PSIsContainer} | ? {$_.LastWriteTime -gt (Get-Date).AddDays(-7)} | out-file \\server\share\New_Media.txt -width 150
Hope this helps others looking for the same thing

Regards,
JDobbsy1987
My System SpecsSystem Spec
Reply

 Batch File - List files modified within last 7 days




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Batch File to Move a list of files.
Hey All, I just joined this forum to find some help on a specific topic that I've been researching for like two hours now on google. I have a list of 1300 files that I need to move from one location to another (move not copy). I've found this batch file created by Neutron16 which performs a Move...
General Discussion
Update last modified time of shortcut when original file is modified?
Assume I have a (log)file and (in another directory) a shortcut which points to this file. Each original file and its shortcut have their own last modified timestamp (as shown in WinExplorer column). Unfortunately when the original file is modified the timestamp of the depending shortcut...
General Discussion
Batch file renaming files but not double
Hello, Got another batch file question. I think I`m close but I`m overlooking something. I have some logging that will get the date of today when I log off. But now if I log off twice the file won`t rename, filename already exists. So I came with a script to just add a number behind the...
Performance & Maintenance
Batch file to copy files from C drive to USB
Hi all, To increase our backup solutions, we have decided to backup our SQL database every hour to a folder within the C drive (we couldn't get it to backup straight to a USB drive). So now we need a way (batch file best solution?) to copy these files to the USB drive, lets say every 1.05hours...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
How to create a batch file that will move files based on the file type
How to create a batch file that will move files based on the file type? My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 20:07.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App