Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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=
:input
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=
:input
share|improve this question
1  
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
1  
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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.