Show newest file in folder (with exclusions)

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
fluor2
Junior Member
Junior Member
Posts: 2
Joined: 2011-10-25, 22:44 UTC

Show newest file in folder (with exclusions)

Post by *fluor2 »

I work a lot with files in my work and often need to archive large folder structures to other servers when the project folder is marked as non-active in our project system. (Large folders fills up our servers so I need to free up space). Unfortunately, people are sometimes still working on files sometimes even if the project folder is marked as non-active in our system.

I need to know Folder size and date of the newest file, but I need to exclude files like thumbs.db and some other files from this counting.

Do anybody know if there exist plugins that can help me achieve this?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6489
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Show newest file in folder (with exclusions)

Post by *Horst.Epp »

This button sets the cursor to the newest file in the current dir.
The icon must be set to some icon on your system.

Code: Select all

TOTALCMD#BAR#DATA
cmd.exe
/k "for /f "usebackq delims=" %%f in (`dir /b /a-d /o-d`) do start "" "%%COMMANDER_EXE%%" /O /S /L="%%~ff\:" & exit"
C:\Tools\Wincmd\Icons\Down-Blue.ico
Newest File

1
-1
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
petermad
Power Member
Power Member
Posts: 14807
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Show newest file in folder (with exclusions)

Post by *petermad »

2fluor2

Here is a buttton to find the newest file - only using TC functions:

Code: Select all

TOTALCMD#BAR#DATA
cm_SrcByName 8,cm_SrcByDateTime 2,cm_GoToFirstFile,cm_SrcByName 9

wcmicons.dll,7
Go to newest file


-1
To make the button:
1. Mark the text in the box here above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctrl+C).
3. Right click on TC's buttonbar and choose "Paste".
I recommend that you add the exclusions to your ignore list: Configuration -> Options... -> Ignore list

If that is not an option for you, then you can filter out the exclusions first - with a button like this:

Code: Select all

TOTALCMD#BAR#DATA
cd *|thumbs.db

wcmicons.dll,24
Hide thumbs.db


-1
I need to know Folder size and date of the newest file
I don't understand this - a file does not have a folder size???

Is you aim to find the folder that contains the newest file?

If that is th case you can first enable Branch view (Ctrl+B), use the first button here above and then press Ctrl+B again followed a press on Backspace - then the cursor wil be on the folder that contains the newest file. If you make some em_commands in your usercmd.ini file, all of this can be combined into one button:

Put this in your usercmd.ini file, which is located the same place as your wincmd.ini file (if it does not exist, just make it as an ASCII txt file):

Code: Select all

[em_hidefiles]
cmd=cd *|thumbs.db

[em_findfolderwithnewestfile]
cmd=em_hidefiles,cm_DirBranch,cm_SrcByName 8,cm_SrcByDateTime 2,cm_GoToFirstFile,cm_SrcByName 9,cm_DirBranch,cm_GoToParent,cm_SrcAllFiles
And make a button with the command: em_findfolderwithnewestfile

you can add more file types to the em_hidefiles command separated by spaces.
Last edited by petermad on 2023-02-08, 09:47 UTC, edited 2 times in total.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2308
Joined: 2020-01-18, 04:03 UTC

Re: Show newest file in folder (with exclusions)

Post by *Fla$her »

petermad wrote: 2023-02-07, 22:48 UTC cm_SrcByName 8,cm_SrcByDateTime 2,cm_GoToFirstFile,cm_SrcByName 9
On the one hand, this is a beautiful solution, but personally it was more convenient for me (even before the appearance of such parameters) to see the list of the latest files:

Code: Select all

TOTALCMD#BAR#DATA
540,325,324,2050

wciconex.dll,217
Jump to newest file
540 (cm_RereadSource) is required here when fast filtering is used. I advise you to add it.
I have a script tied to Alt+Home to hide what is happening in the panel.
Overquoting is evil! 👎
User avatar
petermad
Power Member
Power Member
Posts: 14807
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Show newest file in folder (with exclusions)

Post by *petermad »

2Fla$her
Well without cm_RereadSource I can still use cm_SrcByName 8,cm_SrcByDateTime 2,cm_GoToFirstFile,cm_SrcByName 9 to find the newest file in the filtered list, which can also be usefull.

With the cmd.exe solution that I also used before the 8 and 9 parameters were introduced (on my request), it would be a good idea to use cm_RereadSource and cm_SrcAllFiles first, because the DOS command worked on all files, and it might find a file that was not visible in TC because of one or another kind of filtering.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2308
Joined: 2020-01-18, 04:03 UTC

Re: Show newest file in folder (with exclusions)

Post by *Fla$her »

petermad wrote: 2023-02-08, 00:27 UTCin the filtered list
The task is precisely to remove filtering. She's only getting in the way.
petermad wrote: 2023-02-08, 00:27 UTCWith the cmd.exe solution that I also used before the 8 and 9 parameters were introduced (on my request), it would be a good idea to use cm_RereadSource and cm_SrcAllFiles first
I don't know which solution you are writing about (I can only assume), but in my opinion, the execution of cm_SrcAllFiles looks more selective. You yourself give an example of hiding thumbs.db, and this is only one of the options.
Overquoting is evil! 👎
User avatar
petermad
Power Member
Power Member
Posts: 14807
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Show newest file in folder (with exclusions)

Post by *petermad »

The task is precisely to remove filtering.
I thought the task was to go to the newest file in the displayed list.

I don't know which solution you are writing about
I am talking about this solution, which Horst.Epp showed here above:

Code: Select all

TOTALCMD#BAR#DATA
cmd.exe
/k "for /f "usebackq delims=" %%f in (`dir /b /a-d /o-d`) do start "" "%%COMMANDER_EXE%%" /O /S /L="%%~ff\:" & exit"
C:\Tools\Wincmd\Icons\Down-Blue.ico
Newest File

1
-1
Or as I implemented it:

Code: Select all

[em_ext_gotonewestfile0]
cmd=%COMSPEC% /C
param=if not exist "%P" (echo ) else for /F "usebackq delims=" %%n in (`dir "%P" /b /a-d /o-dn`) do start "" "%%COMMANDER_EXE%%" /O /A /S /L="%P%%n" & exit
menu=Go to newest file
iconic=1

[em_ext_gotonewestfile]
cmd=cm_SaveSelection,cm_SrcAllFiles,em_ext_gotonewestfile0,cm_wait 1000,cm_RestoreSelection
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
petermad
Power Member
Power Member
Posts: 14807
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Show newest file in folder (with exclusions)

Post by *petermad »

You yourself give an example of hiding thumbs.db
Hiding thumbs.db my way with cd *|thumbs.db will not be cancelled by cm_RereadSource
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2308
Joined: 2020-01-18, 04:03 UTC

Re: Show newest file in folder (with exclusions)

Post by *Fla$her »

petermad wrote: 2023-02-08, 01:13 UTCI thought the task was to go to the newest file in the displayed list.
Then there would be no point in cm_RereadSource.
petermad wrote: 2023-02-08, 01:13 UTCOr as I implemented it:
ОК.
petermad wrote: 2023-02-08, 01:22 UTCHiding thumbs.db my way with cd *|thumbs.db will not be cancelled by cm_RereadSource
Of course not. But I wrote about another command:
Fla$her wrote: 2023-02-08, 00:42 UTC the execution of cm_SrcAllFiles looks more selective.
Overquoting is evil! 👎
Post Reply