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 

How to use internal file associations effectively
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Total Commander Forum Index -> Total Commander (English) Printable version
View previous topic :: View next topic  
Author Message
sgp
Senior Member
Senior Member


Joined: 31 Jan 2005
Posts: 306

PostPosted: Fri Aug 13, 2010 4:18 pm    Post subject: How to use internal file associations effectively Reply with quote

How to use internal file associations effectively

wiki tutorial

2012-05-12 edit: Wiki Tutorial updated. Please note that I no longer update the description below. Instead all updates are included just in the wiki tutorial linked above.
Update history:
2012-05-12
Added example of right-click menu for folders.

------
Older post:

Minimum TC version 7.55 required.

I think that TC users who also use portable applications should be aware of TC’s internal file association features, which makes using portable applications fun and easy. You can double-click a data file, say a .JPG file, to open it in its internally associated portable application, say IrfanView (your choice of portable freeware). While one can use TC’s menus to create and manage internal file associations, this post shows how to edit .INI configuration files directly.

So let’s start with the first step, which is to separate out the relevant .INI sections into their own file. By so doing, you end up with a self-contained set of definitions, which you could easily swap in and out of TC by simply renaming a file. We will name this file “associations-searches.INI”.

STEP 1 – create searches-associations.INI
Explore TC’s configuration folder, where file wincmd.INI is located.
Create a new file named associations-searches.INI in that folder.
Open wincmd.INI and locate section [Searches].
- Copy the whole section from wincmd.INI to associations-searches.ini.
- Replace the whole section in wincmd.INI with these lines:
Code:

[Searches]
RedirectSection=associations-searches.INI

Do the same with section [Associations] in wincmd.INI – If you do not find such a section in wincmd.INI still make sure to add these lines to wincmd.INI:
Code:

[Associations]
RedirectSection=associations-searches.INI

Save wincmd.INI, keep associations-searches.INI open.
end of step 1

Let me point out that from now on every time you add a new search to TC that search will end up into associations-searches.INI, even though this search might not be linked to an internal file association.

The next step involves creating a new sample search, which we do want to link to an internal file association. Continuing on the .JPG example, we will create a search named image in step 2.

STEP 2 – create search “image”.INI
Edit section [Searches] of file associations-searches.INI and add the following lines:
Code:

image_SearchFor=*.bmp *.gif *.jpg *.png *.psd *.tif
image_SearchIn=
image_SearchText=
image_SearchFlags=0|000002000020|||||||||0000

Save associations-searches.INI and restart TC.
end of step 2

The new search becomes available under the name image in several TC dialogs, including the search dialog, but that isn’t why we created it. The main reason for creating this new search is to deal with a set of file extensions (bmp, gif, jpg, png, psd, tif) all at once by associating what Windows calls their file type with an application, like step 3 shows.

STEP 3 - associate “image” with IrfanView.INI
Edit section [Associations] of file associations-searches.INI and add the following lines:
Code:

[Associations]
Filter1=>image
Filter1_open=""%commander_path%\..\IrfanView\i_view32.exe" "%1""

Save associations-searches.INI and keep it open.
end of step 3

Note two important points:
You should substitute Filter1 with FilterN+1 if your searches-associations.INI file already includes other N filters, that is, use Filter3 for your new image association if there already are Filter1= and Filter2= lines in your .INI file.
We have used %commander_path%\..\IrfanView\ to specify a relative folder path from TC’s own portable folder. This example assumes that TC’s folder is a sibling of IrfanView’s folder inside your main folder of portable applications.

Now you should verify that when you right click the icon of a .JPG or .PNG file TC’s menu shows Open (internal), which opens the file with IrfanView. Likewise, when you double-click an image file icon IrfanView should open.

Note that you only need to restart TC when you change section [Searches].

Let’s now see how you can associate a second (third, etc…) application to your image type. We will use FastStone Image Viewer (portable freeware).

STEP 4 - associate “image” with FastStone Viewer.INI
Edit section [Associations] of file associations-searches.INI and add the following line:
Code:

Filter1_open-FSViewer=""%commander_path%\..\FSViewer\FSViewer.exe" "%1""

Save associations-searches.INI and keep it open.
end of step 4

Again, you should substitute the right FilterN+1 for Filter1 in the example. Also, we have assumed that folder FSViewer is a sibling of TC’s own folder inside your main folder of portable applications.

You should now verify that when you right click a .JPG or .PNG file icon TC’s menu shows open-FSViewer (internal), which open the image file with FastStone Image Viewer. You may add more applications for the image file type by repeating step 4 for each application.

Let’s finish up our example by changing the icon that TC displays for the image file type. We will change it from IrfanView’s icon to FastStone’s.
STEP 5 - change “image” file type icon.INI

Edit section [Associations] of file associations-searches.INI and add the following line:
Code:

Filter1.icon=%commander_drive%\Portables\FSViewer\FSViewer.EXE

Save associations-searches.INI and restart TC.
end of step 5

When you change an icon you need to restart TC. Note that in step 5 we have used %commander_drive%\Portables\FSViewer\ instead of %commander_path%\..\FSViewer\ which we used in step 4. The two paths must lead to the same folder.

You can now add more file types and associated applications by repeating steps 2-5.

Tips for effective use of internal associations

1. I like to keep the definition of a file type search and its corresponding file associations together, this way:
Code:

[Searches]
; ----- image
;FilterX=>image
;FilterX_open=""%commander_path%\..\IrfanView\i_view32.exe" "%1""
;FilterX_open-FSViewer=""%commander_path%\..\FSViewer\FSViewer.exe" "%1""
;FilterX.icon=%commander_drive%\Portables\FSViewer\FSViewer.EXE
image_SearchFor=*.bmp *.gif *.jpg *.png *.psd *.tif
image_SearchIn=
image_SearchText=
image_SearchFlags=0|000002000020|||||||||0000
[Associations]

At this point, only the search for an image is defined, there is no internal association yet. To add an association append the four FilterX lines to section [Associations], delete the initial semicolon character, and replace X with the correct sequence number. This way of organizing your associations-searches.INI file is tidier when you need to renumber entries as in the next paragraph.

2. To renumber (sort the order of) associations use TC’s File/internal associations dialog (drag and drop to sort items). Remember that when you double-click a file icon TC starts the application that is internally associated with the first file type (search) that matches the file extension.

3. Use %commander_path% and %commander_drive% as the situation dictates. There are some portable programs out there that get confused when you use ..\ in the path. Such programs may not start correctly if you use %commander_path% but may start just fine if you use %commander_drive%, which usually doesn’t need to include ..\ path segments.

4. I am in the habit of writing .INI entries this way:
Code:

Filter1_open=""%commander_drive%\path with spaces\app.exe" /option=value "%1""

Notice the numerous double-quotes. They are essential. The exterior left and write quotes match each other and enclose the whole item, which consists of three words: a quoted application path (with spaces), an option, and a quoted document path. In some cases you might need to write option="value" or even "/option=value" (quote the whole thing).


Last edited by sgp on Sat May 12, 2012 2:47 pm; edited 2 times in total
Back to top
View user's profile Send private message
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24702
Location: Switzerland

PostPosted: Mon Aug 16, 2010 9:21 am    Post subject: Reply with quote

Nice tutorial, thanks! It would be nice if you could put it also in our Wiki:
http://www.ghisler.ch/wiki/index.php/Main_Page

Anyone who has a forum account can use the same user name and password for the Wiki.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
fenix_productions
Power Member
Power Member


Joined: 07 Aug 2005
Posts: 1881
Location: Poland

PostPosted: Mon Aug 16, 2010 12:26 pm    Post subject: Reply with quote

@ghisler(Author)

ghisler(Author) wrote:
Anyone who has a forum account can use the same user name and password for the Wiki.

Not true for me. AFAIR I've been always seeing:

TotalcmdWiki wrote:
Login error
There is no user by the name "fenix_productions". Check your spelling.


It may be related to an underscore in my nickname.
_________________
"When we created the poke, we thought it would be cool to have a feature without any specific purpose." Facebook...

#128099
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sgp
Senior Member
Senior Member


Joined: 31 Jan 2005
Posts: 306

PostPosted: Mon Aug 16, 2010 12:34 pm    Post subject: Reply with quote

ghisler(Author) wrote:
Nice tutorial, thanks! It would be nice if you could put it also in our Wiki
I did. Thank you for your comment! Go to Wiki Tutorial
Quote:

Anyone who has a forum account can use the same user name and password for the Wiki.
It worked for me.
Back to top
View user's profile Send private message
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24702
Location: Switzerland

PostPosted: Thu Aug 19, 2010 7:33 am    Post subject: Reply with quote

Thanks a lot! No idea why it doesn't work for fenix_productions, it may be the underscore or user name length...
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
fenix_productions
Power Member
Power Member


Joined: 07 Aug 2005
Posts: 1881
Location: Poland

PostPosted: Thu Aug 19, 2010 1:21 pm    Post subject: Reply with quote

2ghisler(Author)
Seems to be an underscore issue:
http://www.mediawiki.org/wiki/Extension:LDAP_Authentication/FAQ#Authentication_fails_for_usernames_with_underscores.3B_how_do_I_fix_this.3F
_________________
"When we created the poke, we thought it would be cool to have a feature without any specific purpose." Facebook...

#128099
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Stiltzkin
Junior Member
Junior Member


Joined: 10 Sep 2004
Posts: 60

PostPosted: Sat Aug 21, 2010 11:24 am    Post subject: Reply with quote

is there a way to assign a different icon for every extension with this method?

currently i have every image extension (jpg, gif, png, bmp, etc...) assigned to the same programs with the exception of the icon. the icon is different for every file. but its annoying if i want to change the default program for images.

i tried to overwrite the:

FilterX=>image
FilterX_open=i_view32.exe %1
FilterX_open-FSViewer="FSViewer.exe %1"
FilterX.icon=FSViewer.EXE

with another entry in the [Associations] section:

FilterY=*.jpg
FilterY.icon=icon_jpg.ico

FilterZ=*.png
FilterZ.icon=icon_png.ico

the icon is changed but the associated application is also lost.
Back to top
View user's profile Send private message
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4599
Location: Russian Federation

PostPosted: Sat Aug 21, 2010 11:29 am    Post subject: Reply with quote

You may specify ** as path to icon file - in this case TC will show associated in Windows icons for files that matches this internal association.
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
Stiltzkin
Junior Member
Junior Member


Joined: 10 Sep 2004
Posts: 60

PostPosted: Sat Aug 21, 2010 11:39 am    Post subject: Reply with quote

ok. but this kinda defeats a part of the purpose of the internal associations.
i've also associated many files to portableapps so most of my 'windows-file-associations' are still the default. i specifically want to choose a icon per file extension.
Back to top
View user's profile Send private message
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4599
Location: Russian Federation

PostPosted: Sat Aug 21, 2010 11:46 am    Post subject: Reply with quote

We need multiple internal associations (when multiple items can be applied to same file type) - in this case all will work as expected - e.g. a set of items will set icons and then one common item will set default application for opening theese files. This was suggested yet but wasn't realized (maybe we need to refresh that suggestion topic? Smile).
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24702
Location: Switzerland

PostPosted: Sun Aug 22, 2010 7:44 am    Post subject: Reply with quote

2fenix_productions
Unfortunately I cannot use this workaround, because otherwise users "x_y" and "x y" on the forum will share the same account on the Wiki. Sad

About the icons: Indeed you will need to use different associations if you want different icons.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
neverthelesshello
Member
Member


Joined: 26 Feb 2010
Posts: 136

PostPosted: Mon Sep 13, 2010 3:12 am    Post subject: Reply with quote

I tried this method but it doesnt work for me.
In windows explorer my .rar files are shown with the normal WINRAR icon
I want the same in TC but cant achieve it
using you method I have this in associations-searches.ini

[Associations]
Filter1=>image
Filter1_open=""D:\PROGRAM FILES\IrfanView\i_view32.exe" "%1""
Filter1_open-Imagine=""C:\Totalcmd\plugins\Imagine_1.0.6\Imagine.exe" "%1""
Filter2=.rar
Filter2_open=""C:\Program Files\WinRAR\WinRAR.exe" "%1""
Filter2.icon=C:\Program Files\WinRAR\WinRAR.exe

--------------------------------------
trouble is it doesnt have any effect, I still get the TC icon for a zipped file
_________________
What you dont see is what you get!
Back to top
View user's profile Send private message
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4599
Location: Russian Federation

PostPosted: Mon Sep 13, 2010 3:18 am    Post subject: Reply with quote

neverthelesshello, you can't use internal associations (at least in TC 7.55 and earlier) to change default archive icon which is set by TC. This was discussed many times (e.g. here and here).
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
neverthelesshello
Member
Member


Joined: 26 Feb 2010
Posts: 136

PostPosted: Mon Sep 13, 2010 3:59 am    Post subject: Reply with quote

Thats a pity, hmm, resourcehacker?
ok I suppose thats not allowed, shouldnt there be a different default icon then?
I mean having the same icon for zip and rar files isnt that great they should have their own icon.
_________________
What you dont see is what you get!
Back to top
View user's profile Send private message
petermad
Power Member
Power Member


Joined: 05 Feb 2003
Posts: 5355
Location: Valsted, Denmark

PostPosted: Mon Sep 13, 2010 4:38 am    Post subject: Reply with quote

Quote:
hmm, resourcehacker?


TC will stop working if you change totalcmd.exe.

IIRC you can use custom icons if you disable: "Configuration" -> "Packer" -> "Treat archives like directories".
_________________
#524
Danish Total Commander Translator
Windows XP Home 32bit SP3 & Windows 7 Home Premium 64bit SP1 and Windows 8. TC 8.01 32 + 64bit

Get Extended Total Commander Menus
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> Total Commander (English) All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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