Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is what I have, but I want the text file to go in to the Log file directory with out giving full paths.

@echo off
set dirname=
set /P dirname=Type directory name: %=%
if "%dirname%"=="" goto input

mkdir "%dirname%"_Archive
mkdir "%dirname%"_Errors
mkdir "%dirname%"_Inbound
mkdir "%dirname%"_Outbound
mkdir LogFiles

set text name=
@CON >> "%dirname%"_LogFile.txt

set text name=
share|improve this question
Can you expand on what you mean by "with out giving full paths"? @CON >> %dirname%\LogFiles\_LogFile.txt doesn't work for you? – Ƭᴇcʜιᴇ007 Aug 16 '12 at 23:26
@techie007: Not sure about that part of the question either, but doubtful your suggestion would work unless there happened to already be an existing directory named %dirname%\LogFiles since the script isn't creating one. – martineau Aug 17 '12 at 2:12
@martineau Good catch. – Ƭᴇcʜιᴇ007 Aug 17 '12 at 2:24
Although -- surprisingly to me -- the commands like mkdir "%dirname%"_Archive where you have a quote in the middle of a path appear to work and be ignored, I think it would be safer and more correct to use mkdir "%dirname%_Archive", mkdir "%dirname%_Errors", etc. – martineau Aug 17 '12 at 2:47
This does exactly what I want it to do. – Techturnal Aug 17 '12 at 3:12
up vote 2 down vote accepted

Although I'm a little unsure about what you're asking, but think maybe you need to add a line with chdir Logfiles right after the one with mkdir LogFiles or right before the @CON >> "%dirname%_LogFile.txt". This causes the file which is being created in the current directory do so in the Logfiles directory.

Don't know what you're doing with the set text name= commands, nor the effect having duplicate :input labels might have.

share|improve this answer
Following the correct logic you've pointed out, instead of the change dir perhaps a reference to the current folder, @CON >> .\Logfiles\_Logfile.txt? Regardless, I agree there's a couple freaky things happening in this script. ;) – Ƭᴇcʜιᴇ007 Aug 17 '12 at 2:29
so I create a directory %dirname% which also creates a text file that follows I need to fall into the newly director named LogFiles. that's it the rest workd I'm just stumped on getting the txt file in the dir.Thanks for your help! – Techturnal Aug 17 '12 at 2:32
@Techturnal: I'm confused. Did my answer solve your problem? – martineau Aug 17 '12 at 3:27
@Techturnal: You could use another set /P to get the 'text name' into a variable and then echo "%text_name%" >> "LogFiles\%dirname%_LogFile.txt" (or wherever - it's unclear where you want the file). – paradroid Aug 17 '12 at 4:58
YES! this works now! @CON >> .\LogFiles\%dirname%"_LogFile.txt – Techturnal Aug 18 '12 at 0:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .