Computing.Net > Forums > Programming > create *.txt

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

create *.txt

Reply to Message Icon

Name: Dosnotes
Date: June 24, 2009 at 20:22:41 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

Im wanting to create a blank *.txt document named as ddmmyy.txt in the folder E:\Day notes though am unsure if this is possible via dos scripting?



Sponsored Link
Ads by Google

Response Number 1
Name: Valerie (by Garibaldi)
Date: June 25, 2009 at 01:49:12 Pacific
Reply:

It's a PITD extracting ddmmyy information using a batch script without knowing your date format. Below is a script using both VBS and Batch which will extract the info regardless of date format. By "blank *.txt document" I assume you refer to a 0 (zero) byte file.

:: Code begins...
@echo off
cls
setlocal

set newfile=%temp%\date.vbs

(
echo otherdate = (Date(^)^)
echo   yy = datePart("yyyy", otherdate^)
echo   mm = datePart("m"   , otherdate^)
echo   dd = datePart("d"   , otherdate^)

echo wscript.echo yy^&" "^&mm^&" "^&dd
)>>%newfile%

FOR /F "tokens=1-3" %%A in ('cscript //nologo %newfile%') do (
        set year=%%A
        set month=%%B
        set day=%%C

)

set year=%year:~-2%

del %newfile%

        if %month% lss 10 set month=0%month%
        if %day%   lss 10 set day=0%day%

if not exist "e:\day notes\" md "e:\day notes\"
echo on>"E:\day notes\%day%%month%%year%.txt"
:: Code ends...


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: create *.txt

batch create txt files www.computing.net/answers/programming/batch-create-txt-files/15012.html

VB Create Txt file, single line iss www.computing.net/answers/programming/vb-create-txt-file-single-line-iss/16759.html

With Batch create .txt file www.computing.net/answers/programming/with-batch-create-txt-file/9975.html