Page 1 of 1
GotoNewestFile in a folder
Posted: 2013-03-07, 08:34 UTC
by wanderer
I searched a little but i couldn't find anything related. It would be nice if an internal command (perhaps with a default shortcut - CTRL+SHIFT+N?) existed to place the selection cursor on the newest file in a folder.
Currently this can be achieved by sorting by Date, selecting the first file and then change the sort again to what it was before. With this internal command, if one assigned it to a shortcut, this could be achieved in one step.
There could also be other related commands, like GotoOldestFile, Goto LargestFile, GortoSmallestFile, although i'm not sure they would be as useful as GotoNewestFile.
Posted: 2013-03-07, 12:23 UTC
by MVV
Use button or user-command:
Code: Select all
Command: %ComSpec%
Parameters: /k "for /f "usebackq delims=" %%f in (`dir /b /a-d /o-d`) do start "" "%%COMMANDER_EXE%%" /O /S /L="%%~ff" & exit"
Start path: <empty!>
By playing with
dir sorting flags you can also jump to oldest, largest, smallest file etc. You can get all flags by executing
dir /? in Windows console. Also additional
/tc parameter allows sorting by creation date instead of modify date.
Posted: 2013-04-10, 21:07 UTC
by wanderer
Ha. I had implemented this and forgotten about it for a while (MVV, many thanks BTW) but i just discovered something. If the folder i'm in contains subfolders and files, this command selects the newest subfolder instead of a file and then it enters in it!
Posted: 2013-04-11, 05:40 UTC
by MVV
If you have /o-d flag for dir command, it shouldn't list subfolders, please check your batch.
Posted: 2013-04-11, 07:23 UTC
by wanderer
For some reason, the bold part from here ('dir /b /a-d /o-d') was missing. It now works almost perfectly. I don't know why but it does not work in the root path of the drive, but since i don't put any files there personally i don't care.
Thanks MVV.
Posted: 2013-04-11, 08:54 UTC
by MVV
You're welcome.
Strange, it works for me in a drive root too.
Posted: 2013-04-11, 13:38 UTC
by Horst.Epp
It works fine here even in any drive root
Tested with TC 8.01 x86 and x64 under Windows 7 Ultimate x64
Posted: 2013-04-11, 13:44 UTC
by wanderer

I found out why it doesn't work! The newest file in my C: drive is pagefile.sys, which is hidden. I've set TC to NOT show hid/sys files, so...

Posted: 2013-04-11, 14:29 UTC
by MVV
BTW method really can't work if newest file isn't visible.
Also I think there may be problem if newest file is an archive... So following workaround may be used:
/L="%%~ff\:" instead of just
/L="%%~ff".
Posted: 2013-04-11, 14:37 UTC
by wanderer
MVV wrote:So following workaround may be used
Yup, it works perfectly. Thanks a lot for the help.
