need some help on batchfile (windows 98 pure dos)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jtan2000
Posts: 4
Joined: 29 Jul 2012 15:41

need some help on batchfile (windows 98 pure dos)

#1 Post by jtan2000 » 29 Jul 2012 15:49

Hi I have this batch running on pure dos. However it is not able to search to all directory and subfolder.
I do not know how to program it to seach recursively to find *.gho.

Greatly appreciate if someone can help me on the code.

Thank you. :P


set drive=
if exist E:\*.gho set drive=E:
if exist F:\*.gho set drive=F:
if exist G:\*.gho set drive=G:
if exist H:\*.gho set drive=H:
if exist I:\*.gho set drive=I:
if exist J:\*.gho set drive=J:
if exist K:\*.gho set drive=K:
if exist L:\*.gho set drive=L:
if exist M:\*.gho set drive=M:
if exist N:\*.gho set drive=N:
if exist O:\*.gho set drive=O:
if exist P:\*.gho set drive=P:
if exist Q:\*.gho set drive=Q:
if exist R:\*.gho set drive=R:
if exist S:\*.gho set drive=S:
if exist T:\*.gho set drive=T:
if exist U:\*.gho set drive=U:
if exist V:\*.gho set drive=V:
if exist W:\*.gho set drive=W:
if exist X:\*.gho set drive=X:
if exist Y:\*.gho set drive=Y:
if exist Z:\*.gho set drive=Z:

%drive%
FOR %%l IN (*.gho) do set ghofile=%%l





batch file ===================================


@echo off

rem booting from usb

rem usb stick hd1,1 -- assign c
rem hd c hd2,1 -- assign d
rem hd d hd2,2 -- assign e
rem hd e hd2,3 -- assign f

path a:

rem Check drives for existence of .gho file and return drive letter

set drive=
if exist E:\*.gho set drive=E:
if exist F:\*.gho set drive=F:
if exist G:\*.gho set drive=G:
if exist H:\*.gho set drive=H:
if exist I:\*.gho set drive=I:
if exist J:\*.gho set drive=J:
if exist K:\*.gho set drive=K:
if exist L:\*.gho set drive=L:
if exist M:\*.gho set drive=M:
if exist N:\*.gho set drive=N:
if exist O:\*.gho set drive=O:
if exist P:\*.gho set drive=P:
if exist Q:\*.gho set drive=Q:
if exist R:\*.gho set drive=R:
if exist S:\*.gho set drive=S:
if exist T:\*.gho set drive=T:
if exist U:\*.gho set drive=U:
if exist V:\*.gho set drive=V:
if exist W:\*.gho set drive=W:
if exist X:\*.gho set drive=X:
if exist Y:\*.gho set drive=Y:
if exist Z:\*.gho set drive=Z:


%drive% <------------------------------
FOR %%l IN (*.gho) do set ghofile=%%l <---------------------------

set drive2=
if exist E:\*.gho set drive2=2:2
if exist F:\*.gho set drive2=2:3
if exist G:\*.gho set drive2=2:4
if exist H:\*.gho set drive2=2:5
if exist I:\*.gho set drive2=2:6
if exist J:\*.gho set drive2=2:7
if exist K:\*.gho set drive2=2:8
if exist L:\*.gho set drive2=2:9
if exist M:\*.gho set drive2=2:10
if exist N:\*.gho set drive2=2:11
if exist O:\*.gho set drive2=2:12
if exist P:\*.gho set drive2=2:13
if exist Q:\*.gho set drive2=2:14
if exist R:\*.gho set drive2=2:15
if exist S:\*.gho set drive2=2:16
if exist T:\*.gho set drive2=2:17
if exist U:\*.gho set drive2=2:18
if exist V:\*.gho set drive2=2:19
if exist W:\*.gho set drive2=2:20
if exist X:\*.gho set drive2=2:21
if exist Y:\*.gho set drive2=2:22
if exist Z:\*.gho set drive2=2:23


echo. 
echo * Ghost file %ghofile% at drive %drive%
echo * check if disk:volume %drive2% match the table above else
input " * type the correct disk:volume = " drive2 /E /L4
echo. 

if exist e:\windows GOTO part2

echo ghost.exe -CLONE,MODE=PLOAD,SRC=%drive2%\%ghofile%:1,DST=2:1 -FX
pause
ghost.exe -CLONE,MODE=PLOAD,SRC=%drive2%\%ghofile%:1,DST=2:1 -FX
goto done

:part2

echo ghost.exe -CLONE,MODE=PLOAD,SRC=%drive2%\%ghofile%:1,DST=2:2 -FX
pause
ghost.exe -CLONE,MODE=PLOAD,SRC=%drive2%\%ghofile%:1,DST=2:2 -FX
:done
restart

jtan2000
Posts: 4
Joined: 29 Jul 2012 15:41

Re: need some help on batchfile (windows 98 pure dos)

#2 Post by jtan2000 » 29 Jul 2012 15:53

Hi again, how can i modify code to search through all root directory to find *.gho ?

Thank you.

========================================


set %ghofile= [ Cannot locate ghost file ]

FOR /R %%l IN (*.gho) do set ghofile=%%l


@echo off
echo ghost file = %ghofile%


pause

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: need some help on batchfile (windows 98 pure dos)

#3 Post by foxidrive » 30 Jul 2012 04:58

I see you are using Win98 - is this a boot floppy disk/cd/usb or a command prompt from within Win98?

jtan2000
Posts: 4
Joined: 29 Jul 2012 15:41

Re: need some help on batchfile (windows 98 pure dos)

#4 Post by jtan2000 » 30 Jul 2012 05:23

Hi, this is a floppy image. I use grub4dos to load that floppy image.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: need some help on batchfile (windows 98 pure dos)

#5 Post by foxidrive » 30 Jul 2012 05:57

Ok, so what is the task?

Do you want to find every .gho file on the disk, in every drive?
What will happen if there is more than one .gho file on a drive, in different subdirectories?

What will happen if there are two drives and each one contains a .gho file?

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: need some help on batchfile (windows 98 pure dos)

#6 Post by abc0502 » 30 Jul 2012 06:19

Try this i use it to find my usb drive:

Code: Select all

@Echo Off 
Setlocal
For %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
  IF Exist "%%a:\*.gho" set "drive=%%a:"
)
For /R %%a in (%drive%\*.gho) Do Set "ghofile=%%a"

The ghofile will be the full location of the file like D:\xxxx.gho but if you need the name only change "ghofile=%%a" to "ghofile=%%~na"
and now you have the drive letter D: as %drive% and the file as %ghofile%

But I couldn't understand what you want to do next ?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: need some help on batchfile (windows 98 pure dos)

#7 Post by foxidrive » 30 Jul 2012 07:14

I'm not sure that will work in Win98 dos. The setlocal and the /r will generate an error

It's been a long while - in real MSDOS you need to hide lots of error messages when looking for files on drives that don't exist, and if I recall correctly you need to echo characters to dismiss a prompt while doing it too.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: need some help on batchfile (windows 98 pure dos)

#8 Post by abc0502 » 30 Jul 2012 07:36

I don't know what is pure dos is i thought it is the same, but why he use it?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: need some help on batchfile (windows 98 pure dos)

#9 Post by foxidrive » 30 Jul 2012 07:42

He's looking for ghost disk backup images to restore to a hard drive, and Ghost works from real mode MSDOS (or freedos or dos in Win95/98) when booted from a floppy disk.

It could also boot into real mode dos from a cdrom or USB drive.

jtan2000
Posts: 4
Joined: 29 Jul 2012 15:41

Re: need some help on batchfile (windows 98 pure dos)

#10 Post by jtan2000 » 30 Jul 2012 08:31

First of all thank you so much abc0502 for writing the batch code and foxidrive for your input.

What I am doing is attempting to autoghost back. My norton ghost image is
win71.gho, win72.gho, win73.gho etc.

The batchfile is supposted to look for all drives and subfolders to find the latest ghost images.

I have no problem with my original code if all the *.gho is located at whatever drive root directory but if i
put them on subdirectory such as e:\norton ghost\ then the batch code cannot find the ghost image.

The code abc0520 suggested works well on win7 but I get syntax error in windows 98 dos. Therefore,
is there a better DOS i can use that is more up to date so I can use abc0502's suggested code ?

Note that all drive is formatted NTFS. I use ntfs4dos to assign letter to the drive.


autoexec.bat ----------------

@echo off
prompt $p$g
SET TZ=GHO-08:00


doskey.com /insert
mouse.com
cls

rem /lX Sets the letter of the first used drive. For example, lC means that the first partition detected contains the letter C.
ntfs4dos /lC findG.bat

Post Reply