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
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:\*.*
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?
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.
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\
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%
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.
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...
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
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.
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.
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