views:

418

answers:

4

I have a batch (bat / cmd) file which should act as a filetype handler for jpeg files in Firefox, I just want it to copy the file to another folder, and then open the file in the Picasa Viewer. When I run it from the command line, even if I'm running it from another folder, it works fine, and opens Picasa Viewer. However, when setting it as the handler for jpeg files in Firefox, it only copies the file, but does not start Picasa.

Here is the script (I'm not a batch programmer so this could probably be a lot simpler, was just scraped together from various stackoverflow posts...):

set topath=%~DP0
copy %1 "%topath%"
@echo off

set picpath=%1
set picpath=%picpath:\=;%
set picpath=%picpath: =:%

for /F "tokens=* delims=;" %%i IN (%picpath%) DO call :LAST_FOLDER %%i
goto :EOF

:LAST_FOLDER
if "%1"=="" (
  set LAST2=%LAST::= %
  start explorer "%topath%"
  start "C:\Programfiler\Google\Picasa3\PicasaPhotoViewer.exe" "%topath%\%LAST2%"
  goto :EOF
)

set LAST=%1
SHIFT

goto :LAST_FOLDER

(I also tried opening just explorer on the folder, as seen above.) So, anyone know why neither explorer nor Picasa get started when run from Firefox, but both get started from the console? (Also, explorer gets started when drag-dropping a file on the script, however, Picasa does not...)

A: 

I haven't read it thorough enough to understand it but your path to picasa looks wrong rather than c:\program files\ you have c:\programfiler\

HTH

OneSHOT
I think this is Norwegian for "Program files".
DR
Yeah, for some reason MS decided to localize system directories..silly.
unhammer
Use the environment variable ProgramFiles instead, ex. %ProgramFiles%
RealHowTo
A: 

You may try substituting start by cmd /c start. Maybe that helps.

Joey
Sorry, it didn't :-(
unhammer
+1  A: 

This "feature/bug" I have seen a number of times when using the start command.

The start command is interpreting the the first parameter as the "title" .

Just try this for example : start "c:\windows\system32\calc.exe" "c:\windows\system32\notepad.exe"

It will launch notepad, not calculator

So simply prepend a dummy parameter like this : start "some dummy title" "c:\windows\system32\calc.exe"

It will work fine...

rep_movsd
Now you got my hopes up... I couldn't get this to work either.. (I mean, the weird thing is how it works from the commandline but not from Firefox...)
unhammer
+1  A: 

Looking at your code (Damn, is there a way to copy/paste with the correct alignment on this site? :( ) something like this might help:

jpgviewer.cmd

@echo off
set topath=%~dp0
copy %1 "%topath%"
set file=%~nx1
start explorer "%topath%"
start "-" "%Programfiles%\Google\Picasa3\PicasaPhotoViewer.exe" "%topath%%file%"

Hope this helps.

%~nx0 : Gets the filename+ext of the given variable (here 0) Too bad you didn't see it, it't at the samne place you got ~dp part (help of for).

Jay