The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,810 other followers

Batch files: Remove a trailing backslash (via Jon Kruger’s Blog » Minor batch file tricks)

Posted by jpluimers on 2010/07/23

Even when doing batch files for a long (20+ years!) time, sometimes you learn something new.

Today was such a day.
I wanted to remove a trailing backslash, so I searched with google.

The first hit was a posting by John Kruger showing this little piece of code:

SET Line=C:\Windows\
IF "%Line:~-1%"=="\" SET Line=%Line:~0,-1%
echo %Line% — will output: C:\Windows

(note: copy the code above, be careful with the code on John’s site as somehow his double quotes got mangled).

Note that a stackoverflow answer has the same solution.

–jeroen

via Jon Kruger’s Blog » Minor batch file tricks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: