I've been trying to do the same (i.e. distinguish the sort for folders from files, leaving files sorted by date). A clunky solution for win7 is suggested to me by another superuser post, making use of the 'group by' capabilities. If the file attributes are displayed in explorer (e.g. view > sort by > more... > [check 'attributes']), then you can group by attribute (essentially files vs. folders) using view > group by > attributes, and sort by date modified using view > sort by > date modified. With this, I can get folders to appear at the top, and files underneath this arranged by date.
Why would I want to do this? I'm by no way pedantic in how I organize files, but I do find I end up with a large directory structure - and typically when clicking through this, I'm usually interested in getting to subfolders. When I've reached the folder I want however, I usually will be wanting to access the most recently modified file. So having folders and recently modified files at the top saves scrolling.
Yes, the find
command can do this. It will take some experimentation and reading and re-reading the man page to get it to do what you want, but is amazing command. Below are 2 examples:
find . -type f -ctime -2 -print0 | xargs -0 tar -rvf ~/dev_customer_attributes.tar
find . -mmin -400 > /tmp/files.txt
The 1st find
uses -type f
to list only files. -type d
for directories. -ctime -2
is for files with a created time less than 2 days old and then adds them to the tar archive. I can't remember from when I used this command or why.
The 2nd command checks for files and directories modified within the last 400 days and outputs that list to files.txt
Here's a great info page I just found, too.
Example, In my ~ on my personal laptop are files as old as 2010. And lots that are newer, too. By running find . -ctime -1000 -ctime +600
, I get listing like this:
./Pictures/Photos
./Pictures/Photos/2005
./Pictures/Photos/2005/08
./Pictures/Photos/2005/08/29
./Pictures/Photos/2005/08/29/DSCN1023.JPG
./Pictures/Photos/2009
./Pictures/Photos/2009/02
./Pictures/Photos/2009/02/23
./Pictures/Photos/2009/02/23/img_0001.jpg
./Pictures/Photos/2010
./Pictures/Photos/2010/01
./Pictures/Photos/2010/01/01
./Pictures/Photos/2010/01/01/DSCN2170.JPG
./Pictures/Photos/2010/01/01/DSCN2171.JPG
./Pictures/Photos/2010/06
./Pictures/Photos/2010/06/04
./Pictures/Photos/2010/06/04/img_0111.jpg
./Pictures/Photos/2010/06/04/img_0112.jpg
./Pictures/Webcam/2010-10-03-045227.jpg
./.mission-control
./.mission-control/accounts
./.mission-control/accounts/accounts.cfg
In this case, the Pictures
folder had legacy items copied over from before 2010, but which happened with the 400 day period 600 days ago.
Best Answer
How about PowerShell? This will find all files modified in the last two hours.
Change what's on the right of '-ge' to suit your needs; you can even specify an exact date/time