Computing.Net > Forums > Disk Operating System > Help the Handicapped!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Help the Handicapped!

Reply to Message Icon

Name: peterbrown771
Date: October 15, 2009 at 08:23:21 Pacific
OS: Windows XP
Subcategory: General
Comment:

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 as

set newfilename=$i:r

This would remove the path.

Does anyone know how to do this in DOS?

TIA!



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: October 15, 2009 at 08:33:17 Pacific
Reply:

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=%~nx1

Next time post in the Programming Forum.


0

Response Number 2
Name: peterbrown771
Date: October 15, 2009 at 08:51:09 Pacific
Reply:

Thanks! I had found that ~nx switch before but I had interpreted
the syntax as

set newfilename=%1~nx

and wondered why it didn't work.

Sorry about posting in the wrong forum......


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Help the Handicapped!

More batch help www.computing.net/answers/dos/more-batch-help/11371.html

Help .. cant get into windows XP www.computing.net/answers/dos/help-cant-get-into-windows-xp/15297.html

need help with mscdex www.computing.net/answers/dos/need-help-with-mscdex/9526.html