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,977 other subscribers

Archive for July 23rd, 2010

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.


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

Posted in Power User | Leave a Comment »

%d bloggers like this: