Page 1 of 1

Need help: Setting a unknown path as a variable

Posted: 31 Oct 2009 08:06
by X-Zat
Hey, guys!

(First of all, please excuse my bad English-skilled - I still try to learn English)
I've got a problem with setting an unknown path as a variable. I want to search the file javakarasettings (it's a settings-file of the little program Javakara) and set its path as a variable.
I tried it for a couple of hours and got no ideas left. My Script looks like that:

Javakara-x-JSDK.bat

Code: Select all

@echo off
title Java-SDK- Compiler-Pfad!
dir /S /B *.javakarasettings>"Wo ist Javakara.txt"
for %%i in ('dir /S /B C:\*.javakarasettings;D:\*.javakarasettings | findstr "javakarasettings") do set path=%%j
echo %path%>"Pfad von Javakarasettings.txt"
pause


But this does not work at all. I used Google to search a good solution for my problem but this script is the best (but useless) solution for me...
Well, I am a newbie to coding and Batch-Scripts but this one is really tricky.

I hope that anyone in here can help me!

Bye, X-Zat

EDIT: Well, this line

Code: Select all

dir /S /B *.javakarasettings>"Wo ist Javakara?.txt"
works great but is useless because I want to get the variable without reading a file created by my script :?. And I do not know any way to use

Code: Select all

dir /S /B *.* | findstr "*.javakarasettings"
to get a variable without writing this info into a file...

Posted: 31 Oct 2009 20:42
by isacmahad
Let me make sure I understand before I offer assistance.
Would you like to search the directories for the file javakarasettings and then search the file for a string, or just find the file javakarasettigns and set its path to a variable?
Starting off however you could change this line

Code: Select all

dir /S /B *.* | findstr "*.javakarasettings"

to

Code: Select all

dir /s /b | find ".javakarasettings"

Keep in mind though if there are files .javakarasettings.extension
It will find those as well.

Posted: 01 Nov 2009 04:33
by X-Zat
isacmahad wrote:Let me make sure I understand before I offer assistance.
Would you like to search the directories for the file javakarasettings and then search the file for a string, or just find the file javakarasettigns and set its path to a variable?


Well...
Let me explain this system I want to code:
There is a little program called Kara. Kara is a little bug that you can code. Javakara is the same but coded in java. The problem is that the Java-Compiler is hard to find and the normal *.javakarasettings-file (extension only...) has this path in it but completely wrong.
So I want a batch-file that finds the settings-file and Javac.exe (Java-Compiler) to do the following:

Code: Select all

echo javac.source=%javac-path%>%javasettingsfile%


Or

Code: Select all

echo javac.source=%javac-path%>%javasettingspath%\.javakarasettings


both ways schould work as well.
And i have got one more problem:

dir /S /B does not search in subdirectories :(. It's strange: It searches on my complete HDD D:\ but not in subdirectories of C:\!

Help?

Posted: 01 Nov 2009 15:40
by isacmahad
Im sorry I don't know why you cant find sub directories this command works like a charm on my system. This is new to me. I'm sure someone will be around shortly to help you with this issue. My apologies for not being able to assist you.