newbie question

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
renzlo
Posts: 116
Joined: 03 May 2011 19:06

newbie question

#1 Post by renzlo » 14 Jun 2011 19:48

how do you code in pure batch, a counter that will count characters in a text file?

is it using findstr through regular expressions?

kindly enlighten me.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: newbie question

#2 Post by Cleptography » 14 Jun 2011 20:24

First you open a command prompt then you type in format c: then you learn a real programming language then you realize counting in batch is stupid then you go to your mirror you look into it and then you say to yourself I am a moron.
UNTESTED:
:shock:

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: newbie question

#3 Post by nitt » 14 Jun 2011 20:29

Cleptography wrote:First you open a command prompt then you type in format c: then you learn a real programming language then you realize counting in batch is stupid then you go to your mirror you look into it and then you say to yourself I am a moron.
UNTESTED:
:shock:


Don't be such a jerk.

Anyways, I'm not actually sure. I know each character is a byte, so checking the file size should work.

I do not know how to do this in Batch, so I can use a JavaScript TMP file to do the job for me.

Code: Select all

@echo off
set file=test.txt
echo var wmi = new ActiveXObject("scripting.filesystemobject");var file = wmi.getfile("%file%");WScript.Echo(file.Size); > ~tmp.js
for /f %%a in ('cscript "~tmp.js"') do (set size=%%a)
del ~tmp.js
echo %size%
pause


That will return the size of the file, which is better than just counting the characters because if the file isn't in ASCII it would give you an error.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: newbie question

#4 Post by Cleptography » 14 Jun 2011 20:55

nitt wrote:Don't be such a jerk. Anyways, I'm not actually sure. I know each character is a byte, so checking the file size should work. I do not know how to do this in Batch, so I can use a JavaScript TMP file to do the job for me.

I will stop being a jerk when you stop being such an idiot.
Do you mean javascript or jscript :?: :shock:

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: newbie question

#5 Post by nitt » 15 Jun 2011 01:21

Cleptography wrote:
nitt wrote:Don't be such a jerk. Anyways, I'm not actually sure. I know each character is a byte, so checking the file size should work. I do not know how to do this in Batch, so I can use a JavaScript TMP file to do the job for me.

I will stop being a jerk when you stop being such an idiot.
Do you mean javascript or jscript :?: :shock:


だまれ。あなたはばかです!

JScript, JavaScript, who cares? They are basically the same, except one has more restrictions. And both of them can run this code.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: newbie question

#6 Post by Cleptography » 15 Jun 2011 01:36

Hush nitt you are young and new still learning. Get your facts right.

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: newbie question

#7 Post by nitt » 15 Jun 2011 01:41

Cleptography wrote:Hush nitt you are young and new still learning. Get your facts right.


My facts are right you just are upset.

貴方は悪です!

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: newbie question

#8 Post by Cleptography » 15 Jun 2011 02:41

Why am I upset? I don't have anything to be upset about.

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: newbie question

#9 Post by orange_batch » 15 Jun 2011 03:55

あ。nittさんは日本語ができますね

できませんと思いますw

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: newbie question

#10 Post by renzlo » 15 Jun 2011 04:01

thanks nitt for the reply, i appreciate it. By the way, i can easily write a batch script that will get the byte size just by adding, ~z, but there's a huge difference between them. Like, what if i just want to count characters excluding spaces, i am just wondering if this could be done.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: newbie question

#11 Post by Cleptography » 15 Jun 2011 04:27

I take it orange and nitt just discovered google translate? :roll:

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: newbie question

#12 Post by nitt » 15 Jun 2011 04:41

Cleptography wrote:I take it orange and nitt just discovered google translate? :roll:


No. Some people actually know some Japanese.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: newbie question

#13 Post by Cleptography » 15 Jun 2011 04:45

Yeah and you are not one of them. You lie so bad child.
Shall we examine your dribble?
First you are using an English keyboard.
Second ! is not a Japanese character
Third When you enter that into google translate it translates it perfectly into English
Which anyone speaking any language outside of English will tell you when something
is spoken natively google translate mixes up words.
So, like I said lies lies lies.
It's a lot easier to act smart and get caught being dumb then it is to act dumb and get
caught being smart.

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: newbie question

#14 Post by nitt » 15 Jun 2011 05:03

Cleptography wrote:Yeah and you are not one of them. You lie so bad child.


Do I have to explain everything to you? You're such a troll.

あなたはばかです!

anata ha baka desu!

"Anata" means "you". "ha" can also be written as "wa", but when you are typing you have to write it as "ha". This is just a particle that really doesn't need to be explained for this sentence. Now everyone knows "baka" means "idiot", "stupid", or "fool", the I need to explain the "desu". "Desu" is pronounced "des", not "des-oo". It is a verb meaning "am", "is", or "are". And verbs in Japanese always come at the end of the sentence. This sentence would directly translate to "you stupid are". But due to their sentence structure, it is equivalent to "You are stupid", "You are a fool", or "You are an idiot".

Now for a more complex sentence we could talk about "I walk to the sky". I'm still new to using verbs, so this is not 100% accurate.

But "I" in Japanese can be many things. I tend to use "ore", because using "watashi" can make you sound like a chick. The verb for "walk" is "aruku". And the word for "sky" is "sora" (ever played Kingdom Hearts?). So we would be looking at something similar to
ore ni sora ga aruku

or

俺にそらが歩く。

Like I said, don't trust me. I'm only new to verbs. Even though it translates correctly, you may sound like a scrub saying it. I'm not really sure, never got an professional opinion. I've been teaching myself by translating random sentences mostly.


Now more of a question sentence. Let's say, "What is this"?

This sentence would look more like "this what is?" in Japanese.

"Kore" means "this". "nan" means "what". And we already know the verb for "is". But we also have to note that for a question, we must end it with "ka".

kore wa nan desu ka

これは何ですか?

For a recap, another quick sentence I could show is "Are you Japanese?"

anata wa nihon-jin desu ka

"nihon" means "Japan" and "-jin" means "...person". Like "a Japan person". Or "Japanese".

あなたは日本人か?


Don't take me on for this. Like I've said, I've mostly been teaching myself so I really only get my confirmation from a cheap little translator.



First you are using an English keyboard.


Okay?

Second ! is not a Japanese character


So? Why can't I use that? They do.

Third When you enter that into google translate it translates it perfectly into English


Because I write it to the translator, 'cause I teach myself.

Which anyone speaking any language outside of English will tell you when something
is spoken natively google translate mixes up words.


Yes, so if I translated it with Google Translator it would NOT input correctly

I hope you know that computers in Japan are not programmed in Japanese, but in English. English is taught throughout school years and is required for students to learn. And computers in Japan use Roman keyboards, the same way I use mine. All (Windows) computers have something built in called Windows IME that is what is used. It is just not default in English computer, so you have to enable it yourself in Control Panel.

I'm a bit of a Japanophile. It's actually not hard. You just have to try.

I rest my case.

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: newbie question

#15 Post by orange_batch » 15 Jun 2011 05:17

Haha, you guys. I'm a total Japanophile and I started teaching myself Japanese in 2003. I typed that using Microsoft IME.

この常識非常識OHMYGOD

Post Reply