MSFN Forum: create blank .txt file with a batch file - MSFN Forum

Jump to content



Unattended CD/DVD Guide Homepage · MSFN Forum Rules

If you have questions about customizing Windows XP that are nLite-specific, please post them in the nLite forum, not here. If you have questions regarding the unattended installation of Windows XP, please post them in the Unattended Windows 2000/XP/2003 section.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

create blank .txt file with a batch file how? Rate Topic: -----

#1 User is offline   mb2 

  • Newbie
  • Group: Members
  • Posts: 15
  • Joined: 19-September 05

Posted 02 July 2006 - 01:47 PM

how do u create a new blank .txt file using XP's command prompt? (ie so i can use it in a batch file.)


#2 User is offline   spacesurfer 

  • Pharmassist
  • Group: Patrons
  • Posts: 1,668
  • Joined: 31-July 04
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 02 July 2006 - 02:02 PM

I'm not sure how you can get a blank file but the command

echo >> blank.txt

give you a file with the words "Echo is on."

If you do

echo . >> blank.txt

you'll get a text file with the period.

If you know the escape sequence for the space, you might be able to get a blank file.

#3 User is offline   spacesurfer 

  • Pharmassist
  • Group: Patrons
  • Posts: 1,668
  • Joined: 31-July 04
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 02 July 2006 - 02:13 PM

Or what you can do is create a blank text file somewhere on your drive, then have the batch file copy it to where you want to.

#4 User is offline   mhc 

  • Newbie
  • Group: Members
  • Posts: 21
  • Joined: 02-May 06

Posted 02 July 2006 - 02:38 PM

I'm sure there's a better way to do it, but you can create zero-length files using the DEBUG program. To automate the process you'll first need to create a file (we'll call it TEST.DBG) containing two lines, as follows:

w
q

The first line will tell DEBUG to write a file, the second will end DEBUG. You can now use the TEST.DBG file to create a zero-length file. Here's an example:

DEBUG ZEROLEN.TXT <TEST.DBG

The above command will create a zero-length file of the name ZEROLEN.TXT. A possible limitation is that DEBUG is a DOS program and only understands 8-dot-3 names for files and directories.

You can use this method to change the size of any file to zero bytes, but the TEST.DBG file would be six lines:

rbx
0
rcx
0
w
q

The above is limited to files whose original size was 512K or smaller. It also will not work on .EXE files, or on those which cannot be modified due to lack of permission or read-only status.

mhc

#5 User is offline   Bezalel 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 591
  • Joined: 11-October 05

Posted 02 July 2006 - 03:03 PM

You can run a program that does not produce any output and redirect the output to a text file.
wuauclt > blank.txt

wuauclt was first program I could think of that never produces any output.

If you have a C compiler you can compile this program that does nothing and use it instead of wuauclt.
int main(){}

This post has been edited by Bezalel: 02 July 2006 - 03:05 PM


#6 User is offline   mb2 

  • Newbie
  • Group: Members
  • Posts: 15
  • Joined: 19-September 05

Posted 02 July 2006 - 03:35 PM

excellent, thanks guys.. how do u delete folders (ie not just their contents?) with command prompt also?

edit: what i was trying to do was delete all the ??.lproj folders and their contents except for the en.lproj folders in iTunes. anyway i've created the following batch file to get rid of the ipodservice.exe and ituneshelper.exe processes, as well as all the useless foreign language stuff, as it was getting annoying doing it manually after every update etc.
i've managed to hack it enough to get it to get rid of all the files atleast, but its far from an elegant, simple, solution, and the folders are still there.
can anyone improve?. hopefully it'll be of use to some people too.. (tried to upload as .bat but didn't let me.. :huh: )
taskkill /IM iTunesHelper.exe /F
c:
cd c:\Program Files\iTunes\
del iTunesHelper.exe
type nul>iTuneshelper.exe
attrib +R iTuneshelper.exe
taskkill /IM ipodservice.exe /F
cd c:\Program Files\ipod\bin\
del * /q /f /s
type nul>iPodService.exe
attrib +R iPodService.exe
cd C:\Program Files\iTunes\iTunesMiniPlayer.Resources\
taskkill /IM iTunes.exe /F
move en.lproj ..\
move itunesminiplayer.dll ..\i
del * /q /f /s
move ..\en.lproj .
move ..\i .\itunesminiplayer.dll
cd C:\Program Files\iTunes\iTunesHelper.Resources\
move en.lproj ..\
move ituneshelper.dll ..\
del * /q /f /s
move ..\en.lproj .\
move ..\ituneshelper.dll .
cd C:\Program Files\iTunes\iTunes.Resources\
move en.lproj ..\
move itunes.dll ..\
move itunesregistry.dll ..\
move itunes.qtr ..\
del * /q /f /s
move ..\en.lproj .
move ..\itunes.dll .\
move ..\itunesregistry.dll .
move ..\itunes.qtr .
**** command prompt can be a PITA!
..eh, u sensor the word dam'n now?

This post has been edited by mb2: 02 July 2006 - 08:42 PM


#7 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 02 July 2006 - 04:37 PM

To create a zero byte file called test.txt
type nul>test.txt
To 'delete folders', (if you used the correct terminology, it may be easier to look up), use RD (Remove Directory). For its usage open a command prompt and type & enter
RD /?


#8 User is offline   mb2 

  • Newbie
  • Group: Members
  • Posts: 15
  • Joined: 19-September 05

Posted 02 July 2006 - 04:46 PM

from my reading the problem with RD is that it doesn't accept wildcards..? (see problem edited above^^)

#9 User is offline   LLXX 

  • MSFN Junkie
  • PipPipPipPipPipPipPipPipPip
  • Group: Banned
  • Posts: 3,399
  • Joined: 04-December 05

Posted 02 July 2006 - 07:31 PM

View Postmb2, on Jul 2 2006, 05:46 PM, said:

from my reading the problem with RD is that it doesn't accept wildcards..? (see problem edited above^^)
for %a in ( name* ) do rd %a

Surprising how many ways there are to create a 0-byte file.

This is the recommended solution:
type nul>test.txt


#10 User is offline   mb2 

  • Newbie
  • Group: Members
  • Posts: 15
  • Joined: 19-September 05

Posted 02 July 2006 - 08:44 PM

for %a in ( name* ) do rd %a
sorry.. can u say that some other way i'm not getting it. does %a replace * ..or?

#11 User is offline   pmshah 

  • Member
  • PipPip
  • Group: Members
  • Posts: 292
  • Joined: 10-September 05

Posted 02 July 2006 - 09:05 PM

View Postmb2, on Jul 3 2006, 03:05 AM, said:

excellent, thanks guys.. how do u delete folders (ie not just their contents?) with command prompt also?

edit: what i was trying to do was delete all the ??.lproj folders and their contents except for the en.lproj folders in iTunes. anyway i've created the following batch file to get rid of the ipodservice.exe and ituneshelper.exe processes, as well as all the useless foreign language stuff, as it was getting annoying doing it manually after every update etc.
i've managed to hack it enough to get it to get rid of all the files atleast, but its far from an elegant, simple, solution, and the folders are still there.
can anyone improve?. hopefully it'll be of use to some people too.. (tried to upload as .bat but didn't let me.. :huh: )
taskkill /IM iTunesHelper.exe /F
c:
cd c:\Program Files\iTunes\
del iTunesHelper.exe
type nul>iTuneshelper.exe
attrib +R iTuneshelper.exe
taskkill /IM ipodservice.exe /F
cd c:\Program Files\ipod\bin\
del * /q /f /s
type nul>iPodService.exe
attrib +R iPodService.exe
cd C:\Program Files\iTunes\iTunesMiniPlayer.Resources\
taskkill /IM iTunes.exe /F
move en.lproj ..\
move itunesminiplayer.dll ..\i
del * /q /f /s
move ..\en.lproj .
move ..\i .\itunesminiplayer.dll
cd C:\Program Files\iTunes\iTunesHelper.Resources\
move en.lproj ..\
move ituneshelper.dll ..\
del * /q /f /s
move ..\en.lproj .\
move ..\ituneshelper.dll .
cd C:\Program Files\iTunes\iTunes.Resources\
move en.lproj ..\
move itunes.dll ..\
move itunesregistry.dll ..\
move itunes.qtr ..\
del * /q /f /s
move ..\en.lproj .
move ..\itunes.dll .\
move ..\itunesregistry.dll .
move ..\itunes.qtr .
**** command prompt can be a PITA!
..eh, u sensor the word dam'n now?


Use 4NT as a replacement for cmd.exe It can do really fancy stuff. You can also try 4dos version 7.5 which is now free.

#12 User is offline   mb2 

  • Newbie
  • Group: Members
  • Posts: 15
  • Joined: 19-September 05

Posted 07 July 2006 - 08:12 AM

bump.. (see post 6/10).. (would rather use M$ CMD.exe if possible)

This post has been edited by mb2: 07 July 2006 - 08:15 AM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy