Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: %~n1 question  (Read 6158 times)

0 Members and 1 Guest are viewing this topic.

fmgazette

  • Guest
%~n1 question
« on: May 24, 2006, 03:59:48 PM »
I'm trying to set right-click file options in Windows XP. I'm applying a conversion program to convert DGN files to DXF. The command I have is...

"C:\Program Files\FME\fme.exe" GENTRANS IGDS "%1" ACAD "%1".dxf

It works, but it converts "abcd.dgn" to "abcd.dgn.dxf" - whereas I simply want "abcd.dxf"

From what I saw on this site I thought the %~n1 option would get rid of the ".dgn" part, eg "%~n1".dxf - but all I get is an output file called (you guessed it) %~n1.dxf  ::)

Am I using the %~n1 option incorrectly, or is there another way to achieve this? Any help appreciated.

fmgazette

  • Guest
Re: %~n1 question
« Reply #1 on: May 24, 2006, 04:24:18 PM »
Ah - I see the %~n1 option is only valid under the CALL command  :-[

Still - do you think it's possible to use CALL in this function, or is there another way of achieving what I need?

fmgazette

  • Guest
Re: %~n1 question
« Reply #2 on: May 24, 2006, 04:44:49 PM »
OK - even if that doesn't work - this should...

cmd.exe /k call "C:\Program Files\FME 2640\fme.exe" GENTRANS IGDS "%1" ACAD "%~pn1".dxf

...since CALL also permits %~pn1 - same problem though.  :-?

DosItHelp



    Intermediate
    Re: %~n1 question
    « Reply #3 on: May 24, 2006, 07:56:35 PM »
    fmgazette

    Try

    Code: [Select]
    cmd.exe /c "for %%A in ("%1") do @(C:\Program Files\FME 2640\fme.exe" GENTRANS IGDS "%%A" ACAD "%%~pnA".dxf)"

    DOS IT HELP?

    fmgazette

    • Guest
    Re: %~n1 question
    « Reply #4 on: May 25, 2006, 09:34:45 AM »
    Afraid that doesn't work either. I think we're up against the fact that the Windows file options don't properly expand the ~n part - the pieces of code I listed earlier do work when directly entered onto the command line or run from a bat file, just not when Windows sends it from a right-click menu option. Not sure if there is a way around that issue - I guess I need a different method of removing the .dgn part.

    Thanks for your help anyway   8-)

    MI