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 1,419 other followers

Archive for February 6th, 2018

Anti Patterns Catalog

Posted by jpluimers on 2018/02/06

Recommended for any software developer or architect: browse [Archive.isAnti Patterns Catalog and re-read it 6-12 months later, then contemplate if you have improved.

Summary:

This catalog lists AntiPatterns in two ways:

–jeroen (who is re-reading right now).

via:

Posted in Design Patterns, Development, Software Development | Leave a Comment »

Removing double quotes from variables in batch file creates problems with CMD environment – Stack Overflow

Posted by jpluimers on 2018/02/06

Thanks [WayBackMr. Rick for the answer as this is exactly the bit I needed:

Input:

set widget="a very useful item"
set widget
set widget=%widget:"=%
set widget

Output:

widget="a very useful item"
widget=a very useful item

[WayBackRemoving double quotes from variables in batch file creates problems with CMD environment – Stack Overflow

This trick is convenient in cases like this:

set LocalHostsFile="%windir%\System32\drivers\etc\hosts"
set LocalHostsTemplate="%LocalHostsFile:"=%.template"

The above replaces ALL double quotes with nothing.

If you want to smart replace (like done when de-quoting CSV), you need a bit more complex code like described in [WayBack] batch file – Remove quotes from named environment variables in Windows scripts – Stack Overflow, where you basically have two options:

  • assigning inside a for loop
  • assigning inside a subroutine

Both work because parameters used like %~x do get their quotes removed; you cannot use that syntax on plain variables.

–jeroen

Posted in Batch-Files, Development, Scripting, Software Development | 3 Comments »

 
%d bloggers like this: