Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.

I did not exactly understand you, but would this be what you need?
-- test.bat --
@ECHO offSET mydrive=C:
IF NOT EXIST %mydrive%\path\file.ext SET mydrive=E:

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.

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

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

I'm not clear on what you want to do.
=====================================
If at first you don't succeed, you're about average.M2

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.

![]() |
![]() |
![]() |

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