Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want files ending in .fw.png to open in Adobe Fireworks but I want regular .png files to open in my standard image viewer program.

Is this possible?

share|improve this question
1  
To all voting to close: Initially I thought this question was an exact duplicate, but upon further review, the question being asked does differ significantly enough to warrant a new question. –  Breakthrough Dec 13 '11 at 12:56
    
Not a dupe. Suggested question is for files with exactly the same extension; this is different. –  Hello71 Dec 17 '11 at 23:40
add comment

1 Answer

up vote 6 down vote accepted

Using an AutoIt script, the following should perform what you want:

$FIREWORKS = "C:/Program Files/Fireworks.exe"
$NORMALVWR = "C:/WindowsPictureViewer.exe"

If $CmdLine[0] > 0 Then
    $toRun = ""
    $fExt = StringRight($CmdLine[1], 7)

    ; First, we set $toRun as the proper target program to run.
    If StringLen($CmdLine[1]) >= 7)                 And _
       StringRight($fExt, 4) = ".png"               And _
       StringLeft(StringRight($fExt, 7), 3) = ".fw" Then
        $toRun = $FIREWORKS
    Else
        $toRun = $NORMALVWR 
    EndIf

    ; Next, we append all command line arguments (with a space before each one).
    For $i = 1 To $CmdLine[0]
        $toRun &= ' "' & $CmdLine[$i] & '"'   ; We surround each with quotation marks.
    Next

    ; Finally, run the command in the current working directory.
    Run($toRun, @WorkingDir)
    ; Since the Run() function is asynchronous, this program should close right after.
EndIf

To make this work for your case, you'll need to change those constants up at the top to the proper executables you want to launch. Then, install AutoIt, and compile the script to a .EXE file. Place it in a convent location, and set Windows to open .PNG files with this executable.

I haven't tested this code yet, but it looks like it should work fine. Just for your reference, the compiled program will do the following:

  1. Check if the first argument (if it exists) ends in .fw.png (it is assumed you only run the executable with a .PNG to begin with). If so, the Fireworks executable is launched, otherwise, the normal viewer is launched.

  2. All of the command line arguments are then added again as arguments to the respective application.

  3. The application is called via the AutoIt Run() function, in the current working directory.


If enough people are interested, I can create a full program to do this for any arbitrary set of (nested) file extensions.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.