Reputation: 4740
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...)
Upvotes: 0
Views: 1230
Reputation: 1655
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).
Upvotes: 1
Reputation: 6895
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...
Upvotes: 1
Reputation: 6953
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
Upvotes: 0