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

Here you can propose new features, make suggestions etc.

Moderators: white, sheep, Hacker, Stefan2

Post Reply
petrklic
New Member
New Member
Posts: 1
Joined: 2018-01-13, 05:06 UTC

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

Post by *petrklic » 2018-01-13, 05:32 UTC

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: 3059
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 » 2018-01-13, 11:07 UTC

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 10 x64 October 2018 Update
Version 1809 (OS Build 17763.104)
TC 9.21a x64 and x86, Everything 1.4.1.918 (x64)

User avatar
Hacker
Moderator
Moderator
Posts: 11025
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker » 2018-01-13, 14:47 UTC

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
Senior Member
Senior Member
Posts: 377
Joined: 2013-09-04, 14:07 UTC

Post by *elgonzo » 2018-01-13, 15:49 UTC

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... ;)
Windows 7 Pro x64 SP1

Post Reply