New Posts  All Forums:Forum Nav:

.bat help

post #1 of 9
Thread Starter 
I am trying to make a batch file which asks the user to enter a file name and some text and is saves it in a .txt file. I can make the file and have words in it, but i do not know how to let the user choose the filename through use of a variable, or enter their words also through a variable. This is a school project, so any help is greatly appreciated. here is what i have

ECHO Enter the name of the file:

rem here is where i want to retrieve inputed data and store it the variable "Filename"

ECHO Enter the data you want in your text file:

rem here is where i want to retrieve data and store it in a variable "words"

ECHO Words>>C:\\files\\filename.txt
post #2 of 9
Give me a minute. Plus bumbzors.
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
post #3 of 9
Code:
SET /P file=Choose Name:
SET /P location=Choose Location:

CD %location%

MKDIR %file%
It's ugly but it works.

That just makes a file! Let me fix it.
Edited by GodofGrunts - 12/19/08 at 8:44am
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
post #4 of 9
Quote:
Originally Posted by GodofGrunts View Post
Code:
SET /P file=Choose Name:
SET /P location=Choose Location:

CD %location%

MKDIR %file%
It's ugly but it works.

That just makes a file! Let me fix it.
All you're doing is making a folder somwhere. I don't think that's what he wants. Gimme a sec, and I'll write it.

Code:
@echo off
SET /P file=Choose Name:

SET /P text=Enter Text to be added to file:

echo %text%>>%file%
there you go. It just makes it in the same directory as the batch file. You can add a location like GodofGrunts, and cd there, then run the last step, if you want that functionality. Make sure when you type in filename, you use the .txt extension on the end, or the program won't know what kind of file it is.
Edited by BiG O - 12/19/08 at 8:57am
post #5 of 9
Code:

@echo off
SET /P file=Choose Name:

SET /P location=Choose Location:

SET /P info=Insert what you would like in the file:

CD %location%

ECHO %info% > %file%.txt

ECHO The file can be found at %location%

SET /P seepath=

EXIT
There much better.
Edited by GodofGrunts - 12/19/08 at 9:02am
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
post #6 of 9
Quote:
Originally Posted by BiG O View Post
All you're doing is making a folder somwhere. I don't think that's what he wants. Gimme a sec, and I'll write it.

Code:
@echo off
SET /P file=Choose Name:

SET /P text=Enter Text to be added to file:

echo %text%>>%file%
there you go. It just makes it in the same directory as the batch file. You can add a location like GodofGrunts, and cd there, then run the last step, if you want that functionality. Make sure when you type in filename, you use the .txt extension on the end, or the program won't know what kind of file it is.
Didn't sleep last night so I'm running on empty. I also haven't worked in command prompt in forever lol. Way to beat me to it. I like mine though.
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
post #7 of 9
Quote:
Originally Posted by GodofGrunts View Post
Code:

@echo off
SET /P file=Choose Name:

SET /P location=Choose Location:

SET /P info=Insert what you would like in the file:

CD %location%

ECHO %info% > %file%.txt

ECHO The file can be found at %location%

SET /P seepath=

EXIT
There much better.
That's unnecessary. You can just put pause there. Otherwise, it's fine. Pretty much the same as mine.
post #8 of 9
oh yeah pause... I've been programming in python and bash for the past 4 or 5 months. That was just a quick fix.
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
Damit
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x4 965 Black MSI 790FX-GD70 Asus ATI 5850 4x2 GBs RipJaw DDR3 1066 MHz 
Hard DriveOptical DriveOSMonitor
RAID 0 500 GB WD Black Lite-On Blue Ray, Samsung DVD Arch Linux/Ubuntu 10.04 25.5" Samsung 
KeyboardPowerCaseMouse
PS2 by Compaq 750 Watt COOLER MASTER Elite RC-332-KKN1-GP Death Adder 
Mouse Pad
Custom 
  hide details  
Reply
post #9 of 9
yeah, when you have used Python or even Bash, Batch scripting seems nigh-on hellish. Just no tools at your disposal.
Shinobu
(16 items)
 
Nodoka
(16 items)
 
Index
(4 items)
 
CPUMotherboardGraphicsRAM
Intel Core i5-3570K Asus P8Z77-I Deluxe HD6450 Flex Crucial 16GB (2x 8GB) Ballistix Elite 
Hard DriveHard DriveOSMonitor
Samsung SSD 840 EVO 250GB TOSHIBA DT01ACA300 Arch Linux Dell UltraSharp U2713HM 
MonitorMonitorKeyboardPower
Dell U2410 Dell 2407WFP Cherry - Cherry Blue Switches (Unlabeled keys) Seasonic X-650 
CaseMouseAudioAudio
BitFenix Prodigy Black Logitech M570 Trackball Sennheiser HD595 Creative GigaWorks T20 
CPUMotherboardGraphicsRAM
Intel Core i5 3570K Zotac Z77-ITX WiFi EVGA 680 GTX Samsung 
Hard DriveHard DriveOSMonitor
Samsung 256GB 830 Samsung SpinPoint HD501LJ Windows 7 Dell U2410 
MonitorMonitorKeyboardCase
Dell 2407WFP Dell E248WFP Cherry Black (MX Blue Switches, Blank Keys) Silverstone Sugi SG08B 
MouseAudioAudio
Logitech Trackman Logitech Z-5500 Sennheiser HD595s 
CPUMotherboardRAMHard Drive
AMD Athlon II X2 240e Asus M5A78L-M/USB3 Crucial 8GB (2x4GB) DDR3 1600Mhz Ballistix Sport 1.5TB Hard Drives 
  hide details  
Reply
Shinobu
(16 items)
 
Nodoka
(16 items)
 
Index
(4 items)
 
CPUMotherboardGraphicsRAM
Intel Core i5-3570K Asus P8Z77-I Deluxe HD6450 Flex Crucial 16GB (2x 8GB) Ballistix Elite 
Hard DriveHard DriveOSMonitor
Samsung SSD 840 EVO 250GB TOSHIBA DT01ACA300 Arch Linux Dell UltraSharp U2713HM 
MonitorMonitorKeyboardPower
Dell U2410 Dell 2407WFP Cherry - Cherry Blue Switches (Unlabeled keys) Seasonic X-650 
CaseMouseAudioAudio
BitFenix Prodigy Black Logitech M570 Trackball Sennheiser HD595 Creative GigaWorks T20 
CPUMotherboardGraphicsRAM
Intel Core i5 3570K Zotac Z77-ITX WiFi EVGA 680 GTX Samsung 
Hard DriveHard DriveOSMonitor
Samsung 256GB 830 Samsung SpinPoint HD501LJ Windows 7 Dell U2410 
MonitorMonitorKeyboardCase
Dell 2407WFP Dell E248WFP Cherry Black (MX Blue Switches, Blank Keys) Silverstone Sugi SG08B 
MouseAudioAudio
Logitech Trackman Logitech Z-5500 Sennheiser HD595s 
CPUMotherboardRAMHard Drive
AMD Athlon II X2 240e Asus M5A78L-M/USB3 Crucial 8GB (2x4GB) DDR3 1600Mhz Ballistix Sport 1.5TB Hard Drives 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming