Show / Hide File Extensions

2021 update:

You can now use simple commands for this.

To toggle extensions on and off in the main Name column:

Set HIDEEXT=toggle

To toggle the separate Extension column next to the Name column:

Set COLUMNSTOGGLE=ext(1+Name)

(See How to use buttons and scripts from this forum for how to use the commands.)


Original post:

If you want to 'toggle' whether or not the Name column shows extensions, try this:

Step 1. Create two new STYLES (Settings - Preferences - Listers - Styles):

Create a style with the name ExtOFF:
Click the New Style icon and enter the name - Select the Left file display (and/or Right file display) tab
Check Format - Click Edit - Click the display tab - Check view - Check Hide file extension

Create a style with the name ExtON:
Click the New Style icon and enter the name - Select the Left file display (and/or Right file display) tab
Check Format - Click Edit - Click the display tab - Check view - UNCheck Hide file extension

Step 2. Create a left/right click button to load the two new styles:

<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none" type="three_button">
	<label>Ext</label>
	<button backcol="none" display="label" textcol="none">
		<label>OFF</label>
		<tip>Extensions OFF</tip>
		<function type="normal">
			<instruction>Prefs STYLE=&quot;ExtOFF&quot;</instruction>
		</function>
	</button>
	<button backcol="none" display="label" textcol="none">
		<label>ON</label>
		<tip>Extensions ON</tip>
		<function type="normal">
			<instruction>Prefs STYLE=&quot;ExtON&quot;</instruction>
		</function>
	</button>
</button>

Left click the Button to hide file extensions; Right click the Button to show file extensions

1 Like

Hey Christiaan. Great button! Very useful for me as I default hide my extensions but sometimes want to show to change them. Question:
How to I toggle the highlight of the button so that when extensions are shown, the button is highlighted? Is there a way to toggle highlighting with a three button? I've tried experimenting with new @toggle from 9.1.1.8 but to no avail...

Buttons which set styles are never highlighted as "active" so you can't change when this particular button is highlighted.

(This is because styles are never "active", they just get applied. i.e. If you select a style then its settings are applied to the window but Opus doesn't remember that the settings came from that style.)

Buttons which toggle columns on and off are an example of something that is highlighted, though. So this could be a Show Extensions button that is highlighted when extensions are shown and can be clicked to toggle them:

Set COLUMNSTOGGLE=ext(1)

And, in Opus 9.1.1.8, this could be a Hide Extensions button which does the same but is highlighted when extensions are hidden:

@toggle invert
Set COLUMNSTOGGLE=ext(1)

(When I say show extensions, I mean the Ext column. Whether or not extensions are shown as part of the Name column is part of the folder format. But if you usually don't want to see extensions then you could turn them off for everything, and then use one of my buttons to toggle the Ext column on and off when you need it.)

Thanks for the quick reply, Leo. Too bad highlighting can't be done, but it's more of a nice-to-have. Thanks for your button examples. Will try them out. Appreciate all your work and efforts, as always.

Is there any way this code can be edited to auto-size columns after switching from ExtON to ExtOFF and vice versa...?

Great bit of code as it is though.

You should just need to set the autosize option on within the format which each style sets. The option is on the Display tab of the format.

That doesn't work for me. I have auto-size checked for left and right file displays in both ExtON and ExtOFF styles.

Switching styles manually or using the toolbar button doesn't resize the columns.

As Leo wrote, you should just need to set the autosize option on within the styles. :confused:
But when for some reason it doesn't work for you, you could add this code to the button: Set AUTOSIZECOLUMNS=both
I just tried it and it works for me. Your new button-code to show / hide extensions and to auto-size the columns:

<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none" type="three_button">
   <label>Ext</label>
   <button backcol="none" display="label" textcol="none">
      <label>OFF</label> 
      <tip>Extensions OFF</tip>
      <function type="normal">
         <instruction>Prefs STYLE=&quot;ExtOFF&quot;</instruction>
         <instruction>Set AUTOSIZECOLUMNS=both </instruction>
      </function>
   </button>
   <button backcol="none" display="label" textcol="none">
      <label>ON</label>
      <tip>Extensions ON</tip>
      <function type="normal">
         <instruction>Prefs STYLE=&quot;ExtON&quot;</instruction>
         <instruction>Set AUTOSIZECOLUMNS=both </instruction>
      </function>
   </button>
</button>
1 Like

That method certainly works... thanks guys.

That's great but I have the extension column already visible in list view.
What I need is to show the extension in-line when looking at thumbnails.
Is there an option for that or can I make a button to switch?

Hi there,

this button doesn't work for me. Has anything changed in the meanwhile and the code doesn't work anymore?

Thanks,
Manuel

The thread has a few buttons. Which one are you using? If it's either of Cris's, have you created the ExtON and ExtOFF Styles that it depends on?

yes the button to show/hide extensions. i managed to paste the button code and see the button in UI but it does nothing when i press it.

I'm still not sure which of the four buttons in this thread that show/hide extensions you mean. :slight_smile:

the code in first post

at the end i would like to have a button to toggle the file extension.

image

The button in the first post requires that you make two new lister Styles in Preferences, one called ExtON and one called ExtOFF.

Have you done that the way the first post describes?

Does selecting the styles manually do anything?

Another thing to note is the button in the first post is not a toggle. It's a button where left-click activates the ExtOFF style and right-click activates the ExtON style.

Does this code do what you want?

Set HIDEEXT=toggle

2 Likes

Yes, thank you Crash. Exactly what i was looking for :slight_smile:

1 Like

Good call! I've updated the root post to include that command, since it's so much easier. I forgot it had been added.

1 Like

Show and Hide File Extension is a very Old issue for Directory Opus. Unfortunately Still have no fixed and easy solution.


we need something just control this check box without effect any others folder formatting. Need a toggle button for check or uncheck this option. and the file extension should be hide or unhide all over the Lister without effecting any folder format.
This post method doesn't works perfectly. I usually use content type folder format for all over my Lister. when I Create a new style as this post describe named ExtOFF and another one ExtON and then Click the button for hide extension It's work nicely the first time for the current folder of Left and right file display. but when I have change the location to the other folder then the file extension back to the name column, because the content of the folder display the extension from their content type folder format.

So this is not a perfect solution. That would be great If DOpus able to create a toggle button for just check or uncheck the box "File name extensions" for system wide without effect other folder formats