ZTree.com  | ZEN  | About...  

 Index   Back

different guess   [Tip]

By: Liviu       
Date: Dec 14,2007 at 07:23
In Response to: different guess (Hartmut Schneider)

Here is my latest stab at this, with some more comments below...

:: ** please customize the 'set ZTW=' line below with your ZTreeWin command line **

@if not ["%~1"]==[%1] call :sendToZTree "%*" & goto :eof

:sendToZTree
@echo off
setlocal enabledelayedexpansion
set a1=%~a1
if not defined a1 echo Error: cannot find %1 & pause & goto :eof

set ZTW=C:\ZTree\ZTW.exe /TO /T"*ANSI*" /O

if [%a1:~0,1%]==[d] (
%ZTW% %1 /K,NUM5,
) else (
set p1="%~nx1"
%ZTW% %1 /K,STOP_ON_ERROR,ALT_L,O,RET,f,QUOTE,!p1:,=,COMMA,!,QUOTE,RET,STOP_IF_NOMATCH,f,UP,DEL,ESC,ESC,f,RET,NUM5,
)

This appears to work, to the extent that batch files can possibly work as "send to" targets. In particular, the limitations that I am currently aware of are:

(a) Explorer does not quote pathnames which include caret "^" characters; the cmd command line processor escapes those before passing them on to the batch file, so by the time the arguments are read in the batch file the carets are lost for good and not recoverable.

(b) Explorer does not quote pathnames with special characters which are parsed as argument delimiters by cmd (e.g. comma ",", semicolon ";", equal "=" and possibly others). This makes it difficult to recognize command lines with a single path vs. those with multiple paths (such as when "send to" is invoked on a multiple selection). For example, both "some.bat 1 2 3" and "some.bat 1,2;3" parse argument %1 as "1", %2 as "2" and %3 as "3". The .cmd above assumes one single argument, and will fail with an error if that's not the case.

(c) Pathnames with characters not present in the ANSI codepage will not open, the same way that they would not open in ZTW /O if navigated to manually. I was not able to find a way to detect that case in batch code, so there would be ZTree error(s) popping, instead.

> I've tried %p1:,=,COMMA,% but it doesn't work [...]

With delayed expansion enabled, !p1:,=,COMMA,! seems to work as expected.

> Next time (if time) I'll try an internal "call Label %*" and

I took a similar shortcut of always adding the enclosing quotes, if missing.

Cheers,
Liviu

1,442 views      
Thread locked
 

Messages in this Thread

 
96,637 Postings in 12,231 Threads, 350 registered users, 73 users online (0 registered, 73 guests)
Index | Admin contact |   Forum Time: Mar 29, 2024 - 10:23 am UTC  |  Hits:62,401,493  (16,279 Today )
RSS Feed