Remove New line Char from Text file
Moderator: DosItHelp
Re: Remove New line Char from Text file
You need to double all the \ characters to \\
Re: Remove New line Char from Text file
Try this:
Code: Select all
@set @JScript=1/*
@echo off
setlocal
cscript //nologo //E:JScript "%~f0"
goto :eof
*/
// JScript
//
var ForReading= 1
var ForWriting = 2
var fso = new ActiveXObject("Scripting.FileSystemObject");
// var input = fso.OpenTextFile("c:\\temp\\webconfig.txt", ForReading)
// var output = fso.OpenTextFile("c:\\temp\\newWebConfig.xml", ForWriting, true)
var input = fso.OpenTextFile("Z:\\STG_URS\\1\\115A_CONTRACT_EXPER", ForReading)
var output = fso.OpenTextFile("Z:\\STG_URS\\1\\newfile", ForWriting, true)
var data = input.Readall()
data = data.replace(/\x0A/gi, "")
data = data.replace(/\x0D/gi, "\x0D\x0A")
output.Write(data)
input.Close()
output.Close()
Re: Remove New line Char from Text file
Thanks a Ton FoxDrive.
Its working fine...
another thing that i need to achive. if you can help me out, i m new in batch script.
i need to pole the FTP location , and move the file to my Informatica location, unzip the file (8 files coming as zip rest of files are unzipped).
every 5 mins it will wakeup and check the file, everytime check in my informatica dir whether it reached the count of files like (assume i need to receive 15 files) so if its 15 then create a 0 byte file and stop polling.
Thanks in advance
Its working fine...
another thing that i need to achive. if you can help me out, i m new in batch script.
i need to pole the FTP location , and move the file to my Informatica location, unzip the file (8 files coming as zip rest of files are unzipped).
every 5 mins it will wakeup and check the file, everytime check in my informatica dir whether it reached the count of files like (assume i need to receive 15 files) so if its 15 then create a 0 byte file and stop polling.
Thanks in advance
Re: Remove New line Char from Text file
Start another thread for a new topic.
Provide all the details of the task, like the batch files you are using.
Provide all the details of the task, like the batch files you are using.
Re: Remove New line Char from Text file
Thanks a Ton 

Re: Remove New line Char from Text file
How can i use this script for multiple file, like i have 15 files (can be increase)
can make it like it read all the files from folder and create new files without special char and then remove all the special char file.
sorry , i hv no idea how to achive this
can make it like it read all the files from folder and create new files without special char and then remove all the special char file.
sorry , i hv no idea how to achive this
Re: Remove New line Char from Text file
Just a tip - when you ask for help with a task then make the description complete, so you don't ask for more things once you have a solution.
Often the solution changes a lot with just a small difference in the request.
So use the two batch files below. Name the top one "removechar1.bat" and name the bottom one "removechar2.bat"
Put them both in the same folder.
Change e:\folder\ in the top batch file to where your 15 or more files are, and make sure there are no other files in that folder.
Then run "removechar1.bat" and it should process all the files. Make sure you test it on sample files first.
Often the solution changes a lot with just a small difference in the request.
So use the two batch files below. Name the top one "removechar1.bat" and name the bottom one "removechar2.bat"
Put them both in the same folder.
Change e:\folder\ in the top batch file to where your 15 or more files are, and make sure there are no other files in that folder.
Then run "removechar1.bat" and it should process all the files. Make sure you test it on sample files first.
Code: Select all
@echo off
for %%a in ("E:\folder\*") do (
copy /y "%%a" infile.tmp >nul
call "removechar2.bat"
move /y outfile.tmp "%%a"
del infile.tmp
)
Code: Select all
@set @JScript=1/*
@echo off
setlocal
cscript //nologo //E:JScript "%~f0"
goto :eof
*/
// JScript
//
var ForReading= 1
var ForWriting = 2
var fso = new ActiveXObject("Scripting.FileSystemObject");
// var input = fso.OpenTextFile("c:\\temp\\webconfig.txt", ForReading)
// var output = fso.OpenTextFile("c:\\temp\\newWebConfig.xml", ForWriting, true)
var input = fso.OpenTextFile("infile.tmp", ForReading)
var output = fso.OpenTextFile("outfile.tmp", ForWriting, true)
var data = input.Readall()
data = data.replace(/\x0A/gi, "")
data = data.replace(/\x0D/gi, "\x0D\x0A")
output.Write(data)
input.Close()
output.Close()
Re: Remove New line Char from Text file
Foxdrive Thanks for your great help. its perfectly working...
i have initated new thread for FTP problem, pls look into it.
Thanks in Advance
i have initated new thread for FTP problem, pls look into it.
Thanks in Advance
Re: Remove New line Char from Text file
Scripts involving FTP aren't fun. Maybe someone else will take it up.
Re: Remove New line Char from Text file
Hi when i am running this script is giving me error " out of memory"
any resolution for this " file size is 800 mb
any resolution for this " file size is 800 mb
Re: Remove New line Char from Text file
Increase your RAM or virtual memory, or close other programs when it runs.
Re: Remove New line Char from Text file
foxidrive wrote:Increase your RAM or virtual memory, or close other programs when it runs.
Yep. I used to run into that issue all the time on my old XP computer that only had 1GB of ram. I pretty much new that I couldn't work with files much larger than about 650MB because of all the memory the system was using and all the other apps I was running to do my job.
My new computer at work only has 4GB of ram. I so hate it when companies go cheap on ram. I just built a new computer for my own home use and threw 16GB of ram and it was very inexpensive.
Re: Remove New line Char from Text file
I still use 32 bit Windows so am limited to 3.5 GB ram in Windows 8.
But it serves me well still.
if I had 64 bit then I'd also splash out on 16 GB!
But it serves me well still.
if I had 64 bit then I'd also splash out on 16 GB!
Re: Remove New line Char from Text file
I have 32 GB RAM on my server and still getting the same error., dont know why.
it was working fine on 200 mb file.
it was working fine on 200 mb file.
Re: Remove New line Char from Text file
and 1 more thing.... while giving error" out of memory" its making my data file 0 byte....