I need to convert a unicode text file (19,000K) to an ANSI text file for use with Essbase.
I currently have this written to convert the file but only the first 7800 lines are copying.
This is what I have in my .bat file
cmd /a /c TYPE PVTBHFM_20160708.dat > PVTBHFM_ANSI.dat
What am I missing to fully convert this file?
Is there a way to save the file in a different location?
Related
So i am converting excel files into a .txt files using vbs, and the input file name needs to be the same as the output file name with the changed file extension obviously. Whats making this so hard is the fact that I using this as basically a file converter so the names of the files will be random.
The way I load the input file is by is using the %1 command and just pass in the input file after I call the batch like this.NOTE: the .xlsx can be changed to any .xlsx file that i need to convert.
C:\tabdim>conversion_batch_file.bat **C:\tabdim\2160707.xlsx**
In the batch file (C:\tabdim\conversion_batch_file.bat) Note: the rest of the sql has been replaced with x's.
%windir%\SysWow64\wscript.exe C:\tabdim\combined.vbs **%1**
sqlcmd - xxxxxxxxxxxxxxxxxxxx
bcp xxxxxxxxxxxxxxxx "**C:\tabdim\20160707.txt**" xxxxxxxxxxxxxx
sqlcmd - xxxxxxxxxxxxxxxxxxxx
If there was any way to do something like this
"%1- last 4 characters+".txt""
I know that is totally wrong syntax, I'm just kind of using words to describe kind of what I'm trying to have happen.
I'm sure you know of the special Alt+255 character which Windows renders as a blank character.
I am trying to use that Alt+255 character in a batch file, to create a file that contains this special character.
copy mybatch.txt "C:\Alt+255My Batch.bat" >nul
Result: Alt+255My Batch.bat
So I pasted the actual blank character into the batch file
copy mybatch.txt "C:\ My Batch.bat" >nul
Result: áMy Batch.bat
So I changed the batch file encoding from ANSI to UTF-8
Result:  My Batch.bat
Any ideas how I can refer to the blank character inside a batch file?
I suppose the hex/dec value of this symbol should be ff/255.
to create a file that contain this you can use certutil:
#echo ff>255.hex
#certutil -decodehex 255.hex 255.bin
or you can take a look at GenChr.bat or this or eventually this
I have written one code for remove duplicates from CSV file & now i want to save file with its original name. I dont want to save as with different name. Below is the batch script :
Code :
#echo off
C:\sw\awk\bin\gawk.exe "!x[$0]++" *.csv > "{print FILENAME, $0 > FILENAME ".csv"}" file*
My Objective is : I want to build dynamic batch script which will run on any CSV file. There should not be any type of dependency(file name).
Error is :
The filename, directory name or volume label syntax is incorrect.
Please help me with this.
Thanks.
This batch file is trying to redirect output from gawk into a file called {print FILENAME, $0 > FILENAME, which is not a valid filename.
At present, the gawk code produces a single output that omits all duplicate lines in all of the CSV files in the directory.
If you want to omit duplicate lines from each CSV file individually and write each file out individually, you will need a loop in the batch file to present each CSV file to the gawk script individually and output each modified file individually. You can do that as follows (presuming tmp.tmp is not an existing file in the folder):
for %%f in (*.csv) do (
gawk.exe "!x[$0]++" "%%f" >tmp.tmp
copy tmp.tmp "%%f"
)
del tmp.tmp
As a cautionary note, on DOS or Windows if you write through standard output to a file that you are reading, you can overwrite the file that you are reading before you've finished reading it. That is why the code above writes to a temporary file and then copies the temporary file to the original file.
There are a number of problems with your attempt. Firstly, you cannot write to the same file that you're reading from (at least, not while you're reading from it). Secondly, you're using the awk special variable FILENAME outside of the awk script, where it doesn't exist.
The following may work for a single file at a time. It reads the entire file in, using the line as the key of an associative array and using the line number as the value. Then in the END block, it prints the array out in order of the values, writing to the file it just read.
gawk "!($0 in a) {a[$0] = NR} END {PROCINFO[\"sorted_in\"]=\"#val_num_asc\"; for(x in a) print x >FILENAME}"
I want to create a batch file to copy and replace system file and open an iso in WinArchiver (iso mounter).
This command is not working for copying:
COPY RosettaStoneVersion3.exe C:\Program Files\Rosetta Stone\Rosetta Stone Version 3\RosettaStoneVersion3.exe /y
You need to "quote" any path or filename which contains spaces.
for %%i in (foo bar) do #move %%i dir
This is the content of the batch file. It have to move the file to dir. But it returns error,
C:\>for %i in (foo bar) do #move %i dir
'for' is not recognized as an internal or external command, operable program or batch file.
What it the character  ? I checked with notepad++ and I don't find any hidden char in that batch file.
Most likely you have UTF-8 encoding set in notepad++
You will need to change it to UTF-8 without BOM or ANSI in order to work with cmd (batch)
Strange characters you see at the beginning is BOM - byte order mark code used by UTF
The only thing that comes to mind is encoding. Make sure it's saved in format that cmd will understand (got similar issues when my .cmd file was saved as Unicode Big Endian. Could reproduce your error by saving file as UTF-8. Tried to use ANSI instead.
HTH
Bartek
It looks like you have some hidden characters in it. Try retyping it into a new file. The  definitely shouldn't be there.