Translation Short Cuts in Windows Explorer

From Fmepedia


Table of contents

Q) Can I run an FME quick-translation from within Windows Explorer?

A) Why, yes. Good question. The trick is to set up a file association to call the FME GENTRANS option on a command line.

It's simpler than it sounds. For example to set up a context sensitive option to convert MicroStation to AutoCAD do the following:


Open Windows Explorer.
Choose Tools > Folder Options... (below)

Click on the 'File Types' tab.
Locate the appropriate file extension - in this case .DGN (below)
Click the advanced button.

The file types edit dialog appears. Click on the 'New' button (below)

The new action dialog appears. Enter convert to DXF for the action.
For the application used to perform the action enter...

cmd.exe /k call "C:\Program Files\FME\fme.exe" GENTRANS LOG_STANDARDOUT YES LOG_TIMINGS YES GUI IGDS "%1" ACAD FMEgentrans.dxf

Click OK to close the dialog, click OK again and then click Close. Now the translation is set up. 
Locate a DGN file in Windows Explorer and right-click it. Choose the 'Convert to DXF' option (below)

FME starts up in a command window and the translation parameters dialog appears.
Change the destination name (if required) and click OK to run the translation.

The translation executes and the log window shows it was successful (below)


How can I give the output the same name as the input?

If you want to name the output file as per the input (plus avoid the FME GUI), then you can use this command instead (it should be entered as all one line)...

cmd.exe /c echo call "C:\Program Files\FME 2640\fme.exe" GENTRANS 
 IGDS "%1" ACAD "%~pn1".dxf >> fme_temp.bat && fme_temp.bat "%1" && del fme_temp.bat

NB: This doesn't execute the command directly but writes it to a bat file and executes that. The reason is you can't use "%~pn1" directly - it doesn't appear to work when issued from Windows Explorer, only from a bat file. So now you know! The GUI directive is avoided here since we don't need it to appear.


How can I apply this example to other formats?

With this example you can convert any DGN file to DXF simply by right-clicking it in Windows Explorer, but you can also set up any file based data to convert to any other format using this method. Simply change the IGDS or ACAD to whatever format you need (this short version of the format name is listed in the FME formats gallery) and apply the method to a different file extension in Windows Explorer.


DWG - simply change the dxf extension to dwg...

fme.exe" GENTRANS IGDS "%1" ACAD "%~pn1".dwg

SHAPE - change the format name abbreviation and set the output to be a folder, not a file...

fme.exe" GENTRANS IGDS "%1" SHAPE "%~pn1"


Common format abbreviations are...

BITMAP: BMP
ESRI Shape: SHAPE
ESRI Personal GeoDatabase: GEODATABASE_MDB
FME Feature Store File: FFS
GeoMedia Access Warehouse: FM0
Geography Markup Language: GML
Google Earth: KML
MapInfo MIF/MID: MIF
MapInfo TAB: MAPINFO
MicroStation Design: IGDS

Find a full list in the FME Workbench Formats Gallery.


What other GENTRANS directives can I use?

The GENTRANS directives LOG_STANDARDOUT, LOG_TIMINGS and GUI are all optional. LOG_STANDARDOUT causes log information to be written to the command window and LOG_TIMINGS causes the log to include timings. GUI causes the FME translation parameters dialog to appear - it can be ignored if you are happy with the standard settings.


What other DOS directives can I use?

The DOS /k option causes the command window to open and remain open after translation. If you wish it to close automatically after translation replace this with a /c. You can even change the window color using the /t option.

Simply type...

cmd.exe /?

on the command line to find a full list of permitted DOS switches.

Attached Files
filesizedate
dgn editing - new option.jpg33.3 kB06/04/08
dgn new action.jpg19.9 kB06/04/08
file types - dgn.jpg55.3 kB06/04/08
fme gui.jpg32.2 kB06/04/08
folder options.jpg47.7 kB06/04/08
log window.jpg48.1 kB06/04/08
windows explorer.jpg15.5 kB06/04/08
User Comments Add a new comment