This forum uses cookies. Click X button to hide this message. What is stored? 
Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    Total Commander Forum Index -> TC suggestions (English) Printable version
View previous topic :: View next topic  
Author Message
petrklic
New Member
New Member


Joined: 12 Jan 2018
Posts: 1

PostPosted: Fri Jan 12, 2018 11:32 pm    Post subject: F4 - option to check the file size before editor is launched Reply with quote

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?
Back to top
View user's profile Send private message
Horst.Epp
Power Member
Power Member


Joined: 06 Feb 2003
Posts: 2733
Location: Germany

PostPosted: Sat Jan 13, 2018 5:07 am    Post subject: Re: F4 - option to check the file size before editor is laun Reply with quote

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 Version 1709 (OS Build 16299.192)
Fall Creators Update
TC 9.12 x64 and x86
Back to top
View user's profile Send private message
Hacker
Moderator
Moderator


Joined: 06 Feb 2003
Posts: 10723
Location: Bratislava, Slovakia

PostPosted: Sat Jan 13, 2018 8:47 am    Post subject: Reply with quote

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:
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.
Back to top
View user's profile Send private message Send e-mail
elgonzo
Senior Member
Senior Member


Joined: 04 Sep 2013
Posts: 321

PostPosted: Sat Jan 13, 2018 9:49 am    Post subject: Reply with quote

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

A simple batch file like this should do:
Code:
@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... Wink
_________________
Windows 7 Pro x64 SP1
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> TC suggestions (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group