Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hola Gurus,
I am trying to write a batch file that takes the
input from another batch file (%1) and removes
the path component of the filename. For
example, %1 is e:\plotfiles\a_size.pdf. I want
to set the variable NEWFILENAME to a value
of a_size.pdf so that I may pass it to another
program without the path.I've tried
set newfilename=%1
This gives me the whole shebang. In UNIX I
would be able to write the expression asset newfilename=$i:r
This would remove the path.
Does anyone know how to do this in DOS?
TIA!

As you have poor experience in Microsoft's systems you find what you requested below; however this is not DOS, but NT batch interpreted by cmd.exe not command.com.
set newfilename=%~nx1Next time post in the Programming Forum.

Thanks! I had found that ~nx switch before but I had interpreted
the syntax asset newfilename=%1~nx
and wondered why it didn't work.
Sorry about posting in the wrong forum......

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |