Browse file folder tool

Help with setting up and configuring custom user tools in UltraEdit (based on command line input)

Browse file folder tool

Postby MrBillG » Sun Aug 08, 2004 10:06 am

This is a post from the old Forum but I thought it was so good I wanted everyone see it.
Special thanks to "dmancine" for the orginal post!

"This is a tip, not a question.

I have a "tool" configured that I use all the time that some members of the UE community might find useful (pardon me if it's totally obvious and everyone already knows about it).

It opens the Windows file browser for the directory where the active file lives (hence the Save Active File requirement). I use it all the time, especially when I'm working on a large Java project with lots of deeply-nested packages. I probably use it 50 times a day at least. It probably saves me about 55 hours a day of mousing and clicking around file browser windows.

Command Line: explorer %p
x Windows Program
x Save Active File

Then I bind it to F4. Of course, you can put it wherever you'd like.

I thought since the file browser isn't really a "tool" people may have overlooked this possibility. Or maybe you all know about it. Or maybe it's completely useless. I don't know.

Anyway, enjoy."
User avatar
MrBillG
Advanced User
Advanced User
 
Posts: 65
Joined: Sat Aug 07, 2004 11:00 pm

Re: Browse file folder tool

Postby toddm » Mon Aug 09, 2004 8:11 am

Does anyone know how to get Explorer to load with the "Folders" button checked? I like to have the file tree on the left.

Thanks.
User avatar
toddm
Advanced User
Advanced User
 
Posts: 83
Joined: Wed Jul 28, 2004 11:00 pm

Re: Browse file folder tool

Postby DanKirkd » Mon Aug 09, 2004 1:23 pm

toddm wrote:Does anyone know how to get Explorer to load with the "Folders" button checked?.

Use explorer /e, %p instead.

For a full list of switches go to Command-Line Switches for Windows Explorer

Dan
User avatar
DanKirkd
Basic User
Basic User
 
Posts: 39
Joined: Wed Jul 14, 2004 11:00 pm

Re: Browse file folder tool

Postby DanKirkd » Mon Aug 09, 2004 1:28 pm

Actually, you might like explorer /e,/select,%f better as it also selects the file for you.

Dan
User avatar
DanKirkd
Basic User
Basic User
 
Posts: 39
Joined: Wed Jul 14, 2004 11:00 pm

Re: Browse file folder tool

Postby toddm » Tue Aug 10, 2004 8:11 am

Thanks for the tips.
User avatar
toddm
Advanced User
Advanced User
 
Posts: 83
Joined: Wed Jul 28, 2004 11:00 pm

Re: Browse file folder tool

Postby dmancine » Mon Feb 14, 2005 4:29 pm

Cool! I'm glad to see people like this tip enough that it was carried over to the new forums.

I liked the "select file" suggestions, so now that's how I have mine configured. My new command line is

Code: Select all
explorer /select,"%f"

I don't like the explorer view, just the file folder, so no /e for me. Also, the help files say that %f returns the long version of the file name, and recommends using the quotes. And, though it looks weird, the command line options are actually delimited by commas. Maybe that lets Microsoft parse the long filenames, so %f works without the quotes.
User avatar
dmancine
Newbie
 
Posts: 2
Joined: Mon Feb 14, 2005 12:00 am

Re: Browse file folder tool

Postby 3JB » Tue May 26, 2009 7:43 am

Thanks for this info!

A follow up question: Is there a way to get explorer to default to the project's default folder if no file is selected?

I am using this to launch explorer:
Code: Select all
%SystemRoot%\explorer.exe /e,/select,%f

which works great when a file is open. If no file is open in the editor, it defaults to the desktop. I tried using the /root switch, but this seems to override the other switches.

Hopefully some clarification:

With a project open in UltraEdit, but with no files open in the editor, I would like explorer to launch using the project's default directory. But, if a file is open in the editor, I would like explorer to open with the file selected as it does using the code that I provided.

For example, if the project's default directory is c:\project\, I would like explorer to open here (instead of the desktop, which seems to be the default). But, if a file (c:\project\test.c) is open in the editor, I would like explorer to open with the file selected.

I was previously using something like %SystemRoot%\explorer.exe /e,%rp to open to the project's default directory.

Hope that makes sense!

Thanks.
3JB
Newbie
 
Posts: 7
Joined: Thu May 21, 2009 8:23 am

Re: Browse file folder tool

Postby Mofi » Tue May 26, 2009 9:21 am

Instead of calling explorer directly, create a batch file and pass the name of the current file and the path of the project directory to the batch file. The user tool command is:

"Name of batch file with full path" "%rp" "%f"

The batch file contains something like following:

@echo off
if "%2"=="" goto !NoFile
%SystemRoot%\explorer.exe /e,/select,%2
goto !EndBatch

:!NoFile
if "%1"=="" goto !NoProject
%SystemRoot%\explorer.exe /e,%1
goto !EndBatch

:!NoProject
%SystemRoot%\explorer.exe /e,C:\

:!EndBatch


Note 1: The user tool is now DOS program (console application) and not a Windows program (GUI application). So adapt the program type option of the user tool accordingly.

Note 2: I have not tested if anything written here works. I guess, it the batch file will not work correct if no project is open in UltraEdit, but a file is currently open. You can make the batch file more smart to handle also this situation.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Browse file folder tool

Postby 3JB » Wed May 27, 2009 3:15 pm

Thank you Mofi, I never thought to try a batch file.

Your code worked except for the actual calling of the batch file. It should be like this (no "s):
Code: Select all
"Name of batch file with full path" %rp %f

Thanks again.
3JB
Newbie
 
Posts: 7
Joined: Thu May 21, 2009 8:23 am

Re: Browse file folder tool

Postby Mofi » Thu May 28, 2009 2:17 am

Without double quotes you can pass to the batch file only project folder paths and file names which do not include a space character.

Explorer.exe does not need the double quotes. Explorer.exe is different to all other applications it interprets everything after the program file name as one long parameter string and the command line options are separated with / and , instead of a space. I guess Microsoft has done this to allow users to simply enter a folder path without double quotes in a command line (or double click on a folder) to start explorer with that folder path.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Custom User Tools/Tool Configuration