Computing.Net > Forums > Disk Operating System > Search for right file path if exist

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 right file path if exist

Reply to Message Icon

Name: markreflex
Date: May 10, 2008 at 19:57:11 Pacific
OS: DOS
CPU/Ram: AMD 4GB
Product: HP
Comment:


I am using proper DOS. I have a command ran from a file with arguments but the drive path is likely wrong but the folder path is right. If it wrong how can i search the drives for the right drive path and update the file so it's right. I would just need to update c:\ to e:\ in the file for example but first i have to search it's wrong like i was saying.




Sponsored Link
Ads by Google

Response Number 1
Name: DosX
Date: May 11, 2008 at 12:50:00 Pacific
Reply:

I did not exactly understand you, but would this be what you need?

-- test.bat --
@ECHO off

SET mydrive=C:

IF NOT EXIST %mydrive%\path\file.ext SET mydrive=E:


0

Response Number 2
Name: markreflex
Date: May 12, 2008 at 13:00:48 Pacific
Reply:

Thanks, I explain better. I have a text file with the filepath location eg. C:\docs\cartoon.txt I dont know this location as it not specified by me. The file will exist but the path could be wrong and it be D:\docs\cartoon.txt or another drive letter. How do i search for that path and see if it exists and then if it doesn't exist find the path that does exist and update the filepath. I then have to add that update path as an argument to a command line. I use anything to get it down, as well plus utils. reading the filepath from the text file seems a hard job even to do.


0

Response Number 3
Name: Mechanix2Go
Date: May 12, 2008 at 14:06:51 Pacific
Reply:

for %%d in (c d e f g) do if exist %%d:\docs\cartoon.txt set filepath=%%d:\docs


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: markreflex
Date: May 12, 2008 at 21:39:04 Pacific
Reply:

Yes great that's part of it solved but i don't know the filepath to begin with, it's been saved to a txt file from a user before in Windows. How do i read in C:\docs\cartoon.txt thats the only line from the saved txt file into %%d


0

Response Number 5
Name: Mechanix2Go
Date: May 12, 2008 at 23:45:10 Pacific
Reply:

I'm not clear on what you want to do.


=====================================
If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Response Number 6
Name: markreflex
Date: May 13, 2008 at 17:34:42 Pacific
Reply:


A filepath is saved in Windows to a text file.
In DOS from USB the text file needs to be read to get the filepath.

Due to running it from USB the drive letters are mixed up so the filepath saved in the text file is right apart from the drive letter.

To find the correct path need to read in the filepath from the text file and check that path exists.

If that filepath doesn't exist probably by using

for %%d in (c d e f g) do if exist %%d:\docs\cartoon.txt set filepath=%%d:\docs

I need to read in the filepath into a variable.


0

Sponsored Link
Ads by Google
Reply to Message Icon






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 right file path if exist

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

Batch file - search for file www.computing.net/answers/dos/batch-file-search-for-file/12094.html

If exists/errorlevel www.computing.net/answers/dos/if-existserrorlevel/2107.html