Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Command Prompt

Name: Anonymous 2008-06-29 20:00

Hi, noob here, just requesting a bit of info then I'll be out.
I have a file and I want to read a specific number of bytes then delete a similar succeeding amount.
It would then ignore the bytes after that then continue to delete as mentioned.
Sorry if I was unclear. For example, keep 1 byte, delete the next, keep 1, delete next, etc etc.
I'm guessing you could do this through Windows Command Prompt, but how? Many thanks in advance.

Also if it isn't too much trouble, how could I create a file like  this from two sources?
It would read a portion from 1 file then add a portion from another. Supposedly splicing but hey what do I know.

Name: Anonymous 2008-06-29 20:02


┌┴┴┴┴┴┴┴┴┴┴┐
┤This is an├
┤AIDS virus├
┤ Copy it  ├
┤ help it  ├
┤  spread  ├
└┬┬┬┬┬┬┬┬┬┬┘

Name: Anonymous 2008-06-29 20:08


┌┴┴┴┴┴┴┴┴┴┴┐
┤This is an├
┤AIDS virus├
┤ Copy it  ├
┤ help it  ├
┤  spread  ├
└┬┬┬┬┬┬┬┬┬┬┘

Name: Anonymous 2008-06-29 20:10

>>1

n = the size of the block in bytes
r = the current read position in the file
w = the current write position in the file

Set r to 0
Set w to 0
Open file
Loop this until you reach the end of the file:
   Read n bytes from position r
   Write those n bytes to position w
   Set r to (r+2*n)
   Set w to (w+n)
Set the size of the file to half of its current size
Close file

Name: Anonymous 2008-06-29 20:45

>>5

Many thanks. I get what you've done, but pulling it off is pretty much beyond me already.
It pains me seeing the skip, the write, etc... but getting it into an actual command or something I can run still has me searching.
Is the Command Prompt even an option for this? At the least it looks like I'll have to script it or something.

Name: Anonymous 2008-06-29 20:47

>>5

Crap. Yay for typos and weird quoting.

Name: Anonymous 2008-06-29 20:50

>>5
No, the command prompt doesn't have any commands at a low enough level to do specific reads and writes of files like this. Try some scripting language instead, e.g. Python and look at http://www.diveintopython.org/file_handling/file_objects.html.

Name: Anonymous 2008-06-29 20:56

FIVE SECONDS IN PYTHON:

from sys import argv

i = open(argv[1], 'rb')
o = open(argv[2], 'wb')
n = int(argv[3])

append = True

while True:
    c = i.read(n)
    if len(c) < n:
        break
    if append:
        o.write(c)
    append = not append

Name: Anonymous 2008-06-29 20:57

>>7

Alrighty, thanks again. I'll take my leave now.

Name: Anonymous 2008-06-29 22:03

λ λ

Name: Anonymous 2008-07-02 18:10

Do it in C you prick.

Name: Anonymous 2008-07-02 19:01

>>11
Why?

Name: Anonymous 2008-07-02 19:15

Do it in Java you prick.

Name: Anonymous 2008-07-02 21:25

>>11-13
Do it in CROMA you pricks.

Name: Anonymous 2010-12-21 8:10

Name: Sgt.Kabukiman랙鄠 2012-05-24 9:49

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Name: bampu pantsu 2012-05-29 4:00

bampu pantsu

Don't change these.
Name: Email:
Entire Thread Thread List