F4 - option to check the file size before editor is launched

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
petrklic
Junior Member
Junior Member
Posts: 4
Joined: 2018-01-13, 05:06 UTC

F4 - option to check the file size before editor is launched

Post by *petrklic »

Sometimes, by mistake, I press F4 instead of F3 or F5 key on a large file. Would be nice if TC first checks if the selected file is over some size (user defined value) before launching the editor. Ie if the file is greater than 20 MB, show a dialog window to warn the user.

Is there an option already in TC or is there any possibility to implement this option?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6429
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: F4 - option to check the file size before editor is laun

Post by *Horst.Epp »

petrklic wrote:Sometimes, by mistake, I press F4 instead of F3 or F5 key on a large file. Would be nice if TC first checks if the selected file is over some size (user defined value) before launching the editor. Ie if the file is greater than 20 MB, show a dialog window to warn the user.

Is there an option already in TC or is there any possibility to implement this option?
No, there is no such option and its not on the file manager to do so.
Many editors give you a warning on opening large or binary files
PSpad for example.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3296)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
Hacker
Moderator
Moderator
Posts: 13040
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

petrklic,
You could use a simple script as your "editor" for F4 which would check the filesize and if it fits below the limit call the actual editor, example in AutoHotkey:

Code: Select all

Editor = C:\Program Files\Editor\Editor.exe
FileSizeLimitInBytes = 10000000

FileGetSize, FileSize, % A_Args[1]
IfLessOrEqual, FileSize, %FileSizeLimitInBytes%
	Run, % """" . Editor . """ """ . A_Args[1] . """"
HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
elgonzo
Power Member
Power Member
Posts: 866
Joined: 2013-09-04, 14:07 UTC

Post by *elgonzo »

No need for AutoHotKey or any other 3rd-party scripting solution.

A simple batch file like this should do:

Code: Select all

@echo off
if %~z1 lss <MaxFileSizeInBytes> (
	<PathToEditorExecutable> %1
) else (
	msg %SessionName% File too large for editor
)
Don't forget to replace the placeholders <MaxFileSizeInBytes> and <PathToEditorExecutable> with the respective values.

The batch file expects the file to open in the editor as (first) argument.

By the way, the message box opened by the "msg" command will auto-close after 60 seconds. I also do want to mention a rather minor annoyance of calling a batch file like this with F4 from TC: Whenever you press F4, for a very brief moment a console window will flash on your screen, which you might or might not notice and which you might or might not find annoying. If this is annoying to you, then you might want to use AutoHotKey or other tools that can avoid/suppress showing a (console) window when executing a script... ;)
Begrudgingly back to Windows... now 11... sigh... but i have no nerve for Linux desktop anymore...
Post Reply