Computing.Net > Forums > Disk Operating System > Search for a dir, then use as a var

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Search for a dir, then use as a var

Reply to Message Icon

Name: D
Date: November 6, 2002 at 08:21:32 Pacific
OS: NT
CPU/Ram: PIII 128
Comment:

I have to watch over a bunch of NT machines with each one having certain files located in different locations. Some have the files in C:\ while others have them in G:\ or Z:\

Instead of doing a bunch of if exist statements, can you build a loop to search through all the local drives, locate the file/dir then either use it as a variable or just copy them?

In linux it would be something like this:
$var='find / -type d inetpub'
cp $var /somefolder

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Edwin
Date: November 7, 2002 at 06:36:54 Pacific
Reply:

the way I do it, I use "c:\dir *. /s /b>c:\dirs.txt"
Then I use a scripting tool like KIXstart to build the loop you're talking about

The "instr"-command used bij kix looks for a string in a string, so you can easily find what your looking for
Something like this (its not accurate, doing it from the head)

Open (1,"dirs.txt")
$regel readline (1)
while $regel ""
If Instr ($regel,"datadir")
copy $regel+"\*.*" "destination"
$regel readline (1)
loop

Dowload Kixtart from Kixtart.org


0
Reply to Message Icon

Related Posts

See More


rename batch file Central Point PC Tools



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Search for a dir, then use as a var

Searching for a file? www.computing.net/answers/dos/searching-for-a-file/14715.html

Password for a *.txt file www.computing.net/answers/dos/password-for-a-txt-file/7767.html

PCMCIA CDROM error www.computing.net/answers/dos/pcmcia-cdrom-error/13911.html