TechKnow

Author Topic: [BAT] Simple removal of trailing spaces in variables  (Read 770 times)

0 Members and 1 Guest are viewing this topic.

Offline HcH

  • TechKnow Owner, Ethical Hacker
  • Administrator
  • Uber Member
  • *****
  • Posts: 9936
  • Karma: +2284/-111
[BAT] Simple removal of trailing spaces in variables
« on: November 16, 2015, 11:23:32 AM »
Hello TechKnow members and visitors!

Like everyone probably has experienced, sometimes you need to remove trailing spaces from a variable.

I've seen many tricks to pull this off, even some using linux binaries compiled for Windows.

However, it can be done more easy:

Code: [Select]
:SQUEEZER
if "%TIP:~-1%"==" " set TIP=%TIP:~0,-1%&&goto :SQUEEZER

Just smash those 2 lines in your batch file, it will goto :SQUEEZER every time a trailing space is detected, when no spaces are detected, it will move on.

Sometimes it can be as simple as one would imagine :)

Enjoy!

HcH
« Last Edit: November 16, 2015, 12:19:45 PM by HardcoreHacker »

Offline cyberwind

  • Site Donor
  • Newbie
  • *
  • Posts: 25
  • Karma: +12/-0
  • Uber-Noobie
  • Tablet / Size / Model: homemade/7/galaxy5
Re: [BAT] Simple removal of trailing spaces in variables
« Reply #1 on: November 20, 2015, 10:00:03 PM »
OMG!
This completely is Fantastic ! This is best site ever when it comes to sharing of information and the talent on the board should be considered as an International Think Tank of  Creative and Technical Development . In life no one ever thanks people for kindness and knowledge they have given. Only in years people remember how helpful certain exposer to Knowledge has guided them in life.  This will be on of those sites.

Of Course there is the whole p*ssing off a couple countries due to Malware built in tablets. So let me tell you how to resolve the issue. Just take the countries off any travel plans and there ya go! Some Countries have no sense of humor.

Thanks Everyone!