Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Batch File - Input Directory Name

Original Message
Name: motown01
Date: June 8, 2004 at 11:53:09 Pacific
Subject: Batch File - Input Directory Name
OS: DOS
CPU/Ram: 96 MB
Comment:
I'm creating a batch file that I would like to create a directory name using the user input, and then subdirectories within.

The inputted directory name will be something like "Week Ending June 5, 2004", being more than one word.

Right now I'm using %1 but I'd like to prompt the user to enter a directory name.

Is there a simple way to do this?

@echo off
md %1
cd %1
md tues
md wed
md thur
md fri
md sat
cd tues
echo Insert Tuesday's disk and press any key...
pause
xcopy a:\*.*
cls
cd..
cd wed
echo Insert Wednesday's disk and press any key...
pause
xcopy a:\*.*
cls
cd..
cd thur
echo Insert Thursday's disk and press any key...
pause
xcopy a:\*.*
cls
cd..
cd fri
echo Insert Friday's disk and press any key...
pause
xcopy a:\*.*
cls
cd..
cd sat
echo Insert Saturday's disk and press any key...
pause
xcopy a:\*.*
cls



Report Offensive Message For Removal


Response Number 1
Name: dtech10
Date: June 8, 2004 at 17:18:43 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Is something like this what you want.

To create Weekday.com
1, Create a text file as below press the
return key on every line including the
blank one.
2, Save it as Weekday.txt
3, Enter Debug < weekday.txt

To accept input is a lot harder from Dos
I wrote a c program to accept input and
store it into a environment variable.
with a prompt message.
I take you are working from a dos prompt in
Windows if you want to create a directory
name with spaces in it.
I can email it to you if you can't find
anything thing anywhere on the net to
help.

-------------
a100
mov ah,2a
int 21
mov ah,4c
int21

r cx
8
n weekday.com
w
q
----------------


@echo off
Weekday.com
if errorlevel 0 set day=Sun
if errorlevel 1 set day=Mon
if errorlevel 2 set day=Tue
if errorlevel 3 set day=Wed
if errorlevel 4 set day=Thu
if errorlevel 5 set day=Fri
if errorlevel 6 set day=Sat

cls
cd..
cd %day%
echo Insert %day% disk and press any key...
pause
xcopy a:\*.*



Report Offensive Follow Up For Removal

Response Number 2
Name: wizard-fred
Date: June 9, 2004 at 06:41:36 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
I am going to stir up the "Is it DOS?" debate again. If you are in 'real' DOS then how do you have directories with long file names?

Report Offensive Follow Up For Removal

Response Number 3
Name: motown01
Date: June 9, 2004 at 06:55:42 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
It's a DOS box running under Windows 98. Is there a way for the user to input a name for the first folder, and then the folders for each day will be created within that main folder?

Report Offensive Follow Up For Removal

Response Number 4
Name: wizard-fred
Date: June 9, 2004 at 09:04:07 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
MoTown01: There are ways of doing what you want, but without using batch files. I would use a BASIC program.

The problem is that an increasing number of people think that BATCH files can do everything, and there must be an easily constructed script. You can do a lot more with a script if you use Linux or Unix. However, since the DOSes at not the same calling it DOS when you are in a DOS box will not solve your problem if I give you an answer that does not run in your environment.

Actually I don't mind mixing the environments as long as the poster specifies up front exactly the operating environment that we must consider and not be offended if it is suggested that it go to XP, NT, or Programming forum.


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: June 9, 2004 at 09:05:07 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Hi,

This should do it:

@echo off > quit.bat
@echo echo %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >> quit.bat

echo.
echo This is the world famous %0.bat
echo.
echo copyright 2004 ThaiGuides.com All rights reserved
echo.
echo Free for private use. Others email: Consult@ThaiGuides.com
echo.
echo built and tested on windoze 2000; may act funny on other versions
echo.
echo. The purpose is to create a folder named by user and 7 subfolders, Sun to Sat
echo.

if %1'==' quit Please provide a floder name for %0.bat to create

md "%1 %2 %3 %4 %5"
cd "%1 %2 %3 %4 %5"

for %%D in (Sun Mon Tue Wed Thu Fri Sat) do md %%D

echo Put the Sunday disk in drive A and press any key
pause>nul
xcopy a:\ Sun\

:: And so on through the next six days


HTH


Report Offensive Follow Up For Removal


Response Number 6
Name: Mechanix2Go
Date: June 9, 2004 at 10:00:55 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Hi,

dtech10, Cool weekday.com debug script.

mowtown01, my solution above will work in plain old DOS, but with 8.3 [filename.ext] directories only.

Everyone,

Here's a real DOS challenge:

Write a batch file to put the time, date and day into environment variables using ONLY DOS internals [no debug, no find, nobasic.]

Any contestants?

Mechanix2Go



Report Offensive Follow Up For Removal

Response Number 7
Name: dtech10
Date: June 9, 2004 at 15:16:13 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Hi Mechanix
Thanks I have some more somewhere.
It's just a question of diging out my old
floppies.
I think there was debug scripts for
Weekday,Day,Month,Hour and Minute.
I post them here if anyone is interested and
I can find them.

Here something to get the Date and Time into
the environment, no day.
line 7 would be better with the find command
so to do away with the ctty commands.
which are there to stop error messages.
Tryed in Msdos 6.22 & 5.
ie dir temp0.bat | find "TEMP0
.BAT" > temp1.bat
------------
@echo off
rem Sets DATE & Time environment varables
ctty nul
echo @echo off > temp0.bat
echo set DATE=%%3 >> temp0.bat
echo set TIME=%%4 >> temp0.bat
dir temp0.bat > temp1.bat
call temp1.bat
del temp?.bat
ctty con
echo Date %date%
echo Time %time%


Report Offensive Follow Up For Removal

Response Number 8
Name: jboy
Date: June 9, 2004 at 15:42:55 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Much is covered at Secret_Doom's site


We have nothing against ideas. We're against people spreading them. - General Augusto Pinochet of Chile


Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: June 9, 2004 at 22:28:47 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Hi,

dtech10,

I never thought to use dir xx>some.bat

I always used echo.|time>my.bat

When I started out years ago I didn't know the two bat trick. I was doing echo set var=>a.bat
But of course you get a CRLF with the string. The only way I knew was to use debig to chop off the CRLF.

My solution lets you get time, date AND day into vars. I can post it here, or if nobody else wants it, send it directly to you.

It can be tweaked to work with various DMY order or other languages.

TY

Mechanix


Report Offensive Follow Up For Removal

Response Number 10
Name: Mick C
Date: June 10, 2004 at 11:32:12 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
On my PowerLoad site I support MS-DOS and Win3x as well as Windows 95 which itself is becoming a classic. I call the DOS that comes with 95/98/Me WinDOS and supply bootdisks for all versions for use a recovery or preparation disks. Weinger's 'MS-DOS 7.10' has its uses and I for one do not mind it is not supported by Bill Gates and Co.

Microsoft do in fact have an OEM 32bit LFN version of MS-DOS (6.25) which is a ROM-Based DOS produced for Major Finance Houses and the U.S. Department of Defence for High-Powered Single Task Computers that need 100% reliability (Say no more! - Just try and find a copy!!) Its more or less what MS-DOS 7.10 is anyway....without the extras.

Yes flimflam, like X86 before you (you do really sound like him? LOL)you are anti anything other than Pure DOS But if this forum started that all over again - We tried it once before and X86 left in protest... you would hear the wind blowing in this forum, as it is a lot quieter than it used to be.

Again I say, If you do not like a particular post then ignore it and answer one more to your liking (Thats what I do) Its not that we are overcrowded here in the first place.

I am sick of the 'WinBlows' 'WinBloat' 'WinDoze' and other referances posted here. People come hear for advice not your opinion. I use Windows 98se and Windows XP as well as a DOS/Win3x Laptop. 90% of visiters to PowerLoad do so via Windows, but DOS Bootdisks is my main download.. Work that out.... Love it or hate it Microsoft are the market leader and more computers use Windows than all the other OS's put together and then some. So live with it...

Please reply with a message to let us all know we are on the right track...


Report Offensive Follow Up For Removal

Response Number 11
Name: flimflam
Date: June 10, 2004 at 12:58:05 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Thankyou Mick C, as X86 was banned from only the DOS forum and did not actually leave of his own accord, though JW told him he is welcome to the other Forums which he declined. I have read all X86 posts and admire him wether any body else that is their perogotive.

If I am starting to EMULATE him, well then I am extremely proud!

BTW He has updated yet again:
http://www.mwpms.uklinux.net



Report Offensive Follow Up For Removal

Response Number 12
Name: motown01
Date: June 10, 2004 at 13:46:03 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Thanks for your help, I decided to use the date for my folder name, this is the code:

@echo off
c:
cd\new folder\weekly backup

for /F "tokens=2-4 delims=/ " %%f in ('date /t') do (
set mm=%%g
set dd=%%f
set yyyy=%%h
)

set dat="Backup - %mm%-%dd%-%yyyy%"

md %dat%
cd %dat%

md Tues
md Wed
md Thur
md Fri
md Sat

cls
cd Tues
echo Insert Tuesday's disk.
pause
echo.
xcopy a:\*.*
echo.
cd..
cd Wed
echo Insert Wednesday's disk.
pause
echo.
xcopy a:\*.*
echo.
cd..
cd Thur
echo Insert Thursday's disk.
pause
echo.
xcopy a:\*.*
echo.
cd..
cd Fri
echo Insert Friday's disk.
pause
echo.
xcopy a:\*.*
echo.
cd..
cd Sat
echo Insert Saturday's disk.
pause
echo.
xcopy a:\*.*
echo.
echo The backup has been completed in the %dat% folder.
echo Please insert a blank CD in the CD drive.
pause
start /d "C:\Program Files\Ahead\Nero" Nero.exe


Report Offensive Follow Up For Removal

Response Number 13
Name: dtech10
Date: June 10, 2004 at 16:22:15 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Hi Mechanix
Yes I would be quite interested in your batch file, can you post it here.
Thanks

From your code above I take it you are using
Win 2000/XP. If thats correct you can get direct input like this using the inproved set command.

ie.
Prompt for Weekday and store in %Dir%
set /p Dir=Weekday
You can also do things like this to set %dir%
from data in a file.
set /p Dir=< Dir.txt
You can also do integer maths
set /a WeekNo=%WeekNo%+1
set /a Week=20*3
ect.
Hope this helps.


Report Offensive Follow Up For Removal

Response Number 14
Name: Mechanix2Go
Date: June 10, 2004 at 22:55:20 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Hi dtech10,

Here's the bat to put DAY/DATE/TIME into vars:
****************************************
@echo off
goto start
:: Works in 98SE, booted to DOS 7 [?], no GUI
:: Works in 2k CMD box
:: 12:16 11 June 2004

:: The only reason to flip-flop versions is the output verbage
:: from TIME/DATE
:: ie it uses no 2k cmd extensions like %~blabla
:: Probably can be tweaked to work back to at leasty DOS 3.x

:: Thanks to Laura Fairhead for 'showing the way' to do this without debug


:start
:: This line will clear the vars with any parameter
if not %1'==' goto clear

if %OS%'==Windows_NT' goto NT
goto 9x

:NT

echo.|date>datevar.bat
echo.|time>timevar.bat

echo set DATEvar=%%5>the.bat
call datevar

echo set DAYvar=%%4>the.bat
call datevar

echo set TIMEvar=%%4>the.bat
call timevar

goto cleanup
goto end

:9x

echo.|date>datevar.bat
echo.|time>timevar.bat

echo set DATEvar=%%4>current.bat
call datevar

echo set DAYvar=%%3>current.bat
call datevar

echo set TIMEvar=%%3>current.bat
call timevar

:cleanup

for %%B in (the.bat datevar.bat timevar.bat current.bat) do if exist %%B del %%B

goto end

:clear

set TIMEvar=
set DATEvar=
set DAYvar=

:end
**************************************
Hope someone can find it useful.

Here's a good one for you. Without line#2 goto start, 2k reads line#9 and spits out this msg:

The following usage of the path operator in batch-parameter
substitution is invalid: %~blabla

So why, pray tell, does it ignore almost anything else beginning with :: and 'look at' this one.

Curiouser and curiouser.

RocketScienceDept@Golden-Triangle.com



Report Offensive Follow Up For Removal

Response Number 15
Name: dtech10
Date: June 12, 2004 at 15:11:05 Pacific
Subject: Batch File - Input Directory Name
Reply: (edit)
Thanks Again Mechanix
Great Info on other ways of doing things in
batch files.



Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch File - Input Directory Name

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




how to setup call of duty to joytok

WindowsME / HotMail Problem

Corrupt memory

Convert fat32 to Ntfs

Best WinMo phone of 2008


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC