Reputation: 1
Is there a way to use a batch file to open .txt files and remove anything that is not numbers or letters (also leaving the tabs and spaces).
I am new to writing batch files but I think this is the best option for what I need to do.
Background
I have .qrd files (can be open as .txt files) and I use VBA to open them and add the information required to excel for reporting reasons.
My issue is that some of the files have little blocks in, I am assuming they are unrecognizable characters from the database, this plays havocs with my VBA/Reports.
Any thoughts welcome, I have been searching for a while now and have figured out how to delete characters from a batch file but not how to delete anything that doesn't match a criteria.
Upvotes: 0
Views: 1753
Reputation: 975
Well, batch isn't the best language to do this in,stability and speed wise. However it can be done.
@echo off
setlocal enableDelayedExpansion
:[ replace '█' with whatever you may have via copy/paste ]
:[ to replace all '█' with spaces; ]
set "variable=!variable:█= !"
:[ to delete all '█' without leaving spaces; ]
set "variable=!variable:█=!"
Upvotes: 1