WIndows Batch Script to remove multiple special characters from a text file

I have a text file which has lot of special characters. From that test file, I would like to remove three special characters(~ œ <). Can someone please provide me a script to address my need? I tried with some scripts but it doesn't seem to be working for the character ~.

-------------Problems Reply------------

You can use sed to execute this, download it here -

sed "s/[^a-zA-Z0-9]//g" file.txt

If you have latest, Windows 7 or higher version, you can do something like this in PowerShell

Get-Content file.txt | foreach { $_ -replace '[^\w\d]' } | Out-File -Encoding UTF8

OR, Download Ruby for windows

C:\>ruby -ne 'print $_.gsub(/[~)œ\[\]<]/,"")' file


Category:windows Views:50 Time:2018-03-16
Tags: windows

Related post

  • Removing special characters( from a text file 2012-02-13

    I have a text file with some special unseen character in it .Is there any way to remove such special character .I have tried using sed in vim editor but it doesnot work and moreover gedit and kwrite doesnot show these characters ാര യാതരയകകിടെ യാതരകകാ

  • Java - Can't read in special characters from a text file 2012-02-29

    I am writing a program which searches for words in a text file (say B) in another dictionary text file (say A) to compare efficiencies of different sorting algorithms. Anyway, my problem is when one of these source text files has a special character

  • RXReplace function - Function that removes spaces and special characters from a text string 2012-04-10

    Years ago I had a database set up that used a function that I thought was called RXREPLACE. It removed all spaces and special characters from a text string. Unfortuanately, the database is long gone and I'd like to recreate the function in case we ne

  • Code sample to remove all special characters from data stored in MYSQL? 2010-10-19

    Does anyone have a code sample where I can to remove all special characters from data stored in MYSQL? I need to remove the following special characters: : [email protected]#$%*()_+{}[];':"<>? --------------Solutions------------- Try this... It looks terribl

  • Delete last 10 characters from a text file 2009-08-13

    Is there any way to Delete last 10 characters from a text file ? Thanks --------------Solutions------------- For single-byte encoding on POSIX platform you can use something like this (error handling omitted): FILE *file = fopen("filename", "a"); fse

  • Regex to remove all special characters from string? 2010-07-21

    I'm completely incapable of regular expressions, and so I need some help with a problem that I think would best be solved by using regular expressions. I have list of strings in C#: List<string> lstNames = new List<string>(); lstNames.add

  • Remove all special characters from a string in R? 2012-04-24

    How to remove all special characters in a given string in R and replace the special characters with a space? The special characters to remove are : [email protected]#$%^&*(){}_+:"<>?,./;'[]-= --------------Solutions------------- You need to use regular e

  • Running a Windows Batch Script to Startup Multiple Files 2008-11-13

    I'm trying to replace the programs that run from my startup directory with a batch script. The batch script will simply warn me that the programs are going to run and I can either continue running the script or stop it. Here's the script as I have wr

  • Remove multi-line strings from a text file using a batch script 2010-07-19

    I am trying to create a batch file that will edit a text file to remove lines that contain a certain string and remove the line directly after that. An example of this file would look like this: LINE ENTRY KEEP_1 BLA BLA END LINE ENTRY REMOVE_1 FOO B

  • How to remove all special characters from URL? 2010-03-15

    I have my class public function convert( $title ) { $nameout = strtolower( $title ); $nameout = str_replace(' ', '-', $nameout ); $nameout = str_replace('.', '', $nameout); $nameout = str_replace('æ', 'ae', $nameout); $nameout = str_replace('ø', 'oe'

  • Remove multiple duplicate characters from string 2012-04-13

    I have strings like this one: $str = 'This -----is a bbbb test'; How can I remove all duplicate characters if it occurs more than 3 times? So, for example, the string above must look as follows: 'This is a test'; --------------Solutions-------------

  • How to get rid of special characters in a text file? (*nix) 2009-07-13

    I've got a source code file, that started as a copy of some sample code from a webpage. It was created and edited under Windows and compiled with no problems. But under Mac's I get a load of obscure errors, like: ../MyProgram.cpp:1: error: stray '\25

  • Removing unknown characters from a text file 2010-11-25

    I have a large number of files containing data I am trying to process using a Python script. The files are in an unknown encoding, and if I open them in Notepad++ they contain numerical data separated by a load of 'null' characters (represented as NU

  • Batch File to read 'N' characters from a text file 2011-12-21

    I have searched this across the net and found many codes for retrieving the entire line from a text or replacing the text with another but not for what i was looking for. Using the For loop with the tokens would return on the set (word) separated wit

  • C Remove the first line from a text file without rewriting file 2010-04-17

    I've got a service which runs all the time and also keeps a log file. It basically adds new lines to the log file every few seconds. I'm written a small file which reads these lines and then parses them to various actions. The question I have is how

  • Quickly remove first n lines from many text files 2010-08-19

    I need to create an output text file by deleting the first two lines of the input file. At the moment I'm using sed "1,2d" input.txt > output.txt I need to do this for thousands of files, so am using python: import os for filename in somelist: os.

  • How to read characters from a text file, then store them into a hash in Ruby 2011-10-04

    I am working on an assignment, and can't figure it out. We have to first parse a text file, and then feed the results into a hash. I have done this: code = + '/code.txt','r') char_count = {'a' => 0,'b' => 0,'c' => 0,'d'

  • How to read a specific amount of characters from a text file 2012-03-01

    I tried to do it like this #include <iostream> #include <fstream> using namespace std; int main() { char b[2]; ifstream f("prad.txt"); f>>b ; cout <<b; return 0; } It should read 2 characters but it reads whole line. This work

  • Windows batch script which removes text in brackets from filenames? 2012-04-16

    I have a bunch of files in a folder which I'd like to copy and rename via a .bat or .vbs script (or similar). The files are named as such: ABC-DE-(XXX)SomeNameHere.dat I'd like to copy the files and rename them, removing the (XXX) part, leaving simpl

  • How do i remove   - – special characters from my XML files 2010-07-27

    this is a sample of the xml file <row tnote="0"> <entry namest="col2" nameend="col4" us="none" emph="bld"><blst> <li><text>Single, head of household, or qualifying widow(er)—$55,000</text></li> <li><

  • Removing control / special characters from log file 2011-11-25

    I have a log file captured by tclsh which captures all the backspace characters (ctrl-H, shows up as "^H") and color-setting sequences (eg. ^[[32m .... ^[[0m ). What is an efficient way to remove them? ^[...m This one is easy since, I can just do "se

  • How to Remove (alphabet & Special )characters from a String and store to one array? 2012-01-12

    my String Data is like DV_APLCN: 563 ,DV_DHR_APLCN: 5632, PIC_NOTE: 6254...etc. So I need to separate only digit( i.e ,563,3632,6254)s and need to store in an array. Help me on this.with sample code. data is very huge and different StringNames. -----

  • Reading non-ASCII characters from a text file 2012-04-29

    I'm using python 2.7. I've tried many things like codecs but didn't work. How can I fix this. myfile.txt wörd My code f = open('myfile.txt','r') for line in f: print line f.close() Output s\xc3\xb6zc\xc3\xbck Output is same on eclipse and command win

  • Removing tab delimited spaces from a text file using for loop 2011-03-21

    For my python class, I am working on opening a .tsv file and taking 15 rows of data, broken down in 4 columns, and turning it into lists for each line. To do this, I must remove the tabs in between each column. I've been advised to use a for loop and

Copyright (C), All Rights Reserved.

processed in 0.188 (s). 11 q(s)