Command line wildcards to load clone with ghost 8.3

mchadek

Distinguished
Aug 31, 2011
7
0
18,510
Is there anyway I can use a wild card with this script so I can load any image that would be in this folder?

C:\ghost\ghost -Clone,Mode=PLoad,src=C:\Images\*.gho:1,dst=1:1 -sure -fx

Thanks for the help
 
Solution
Ok, here is a small script I put together. It should work with a single file in a chosen directory. Copy into a batch file and try.

@ECHO OFF

SET ghostpath=C:\image

DIR "%ghostpath%\*.gho" /b > tmpghost.txt
FOR /f "tokens=1" %%a IN (tmpghost.txt) DO SET filename=%%a
C:\ghost\ghost -Clone,Mode=PLoad,src=%ghostpath%\%filename%:1,dst=1:1 -sure -fx
IF EXIST tmpghost.txt DEL tmpghost.txt
How will the program know which file to use if you can use wildcards? What if you have 3 images in the directory? You can't expand all 3 on the same computer, how can it pick? At best you'd get the first image in alphabetical order loaded.

You can use wildcards in batch files sure, like "Copy *.txt", that will work because you are just telling the copy command to copy every txt file it sees. You can't tell the ghost program to load every file it sees, won't work.
 

mchadek

Distinguished
Aug 31, 2011
7
0
18,510
In this case there will on be one .gho file in the folder. But it won't always be the same name. I was wanting to just tell it to load the file that it sees without having to tell it the name.
 

ricno

Distinguished
Apr 5, 2010
582
0
19,010


So in a certain directory there will be one singe file, with the extention .gho, but different filename every time? I think I can create a small script if that is correct.
 

mchadek

Distinguished
Aug 31, 2011
7
0
18,510
Yes that's correct. Right now I use this script without the wild card to restore images. I have about 6 images that are stored in a different folder. This folder will be used to store different custom images. But only one .gho image file will be in the folder at a time.


C:\ghost\ghost -Clone,Mode=PLoad,src=C:\Tempimg\*.gho:1,dst=1:1 -sure -fx
 

ricno

Distinguished
Apr 5, 2010
582
0
19,010
Ok, here is a small script I put together. It should work with a single file in a chosen directory. Copy into a batch file and try.

@ECHO OFF

SET ghostpath=C:\image

DIR "%ghostpath%\*.gho" /b > tmpghost.txt
FOR /f "tokens=1" %%a IN (tmpghost.txt) DO SET filename=%%a
C:\ghost\ghost -Clone,Mode=PLoad,src=%ghostpath%\%filename%:1,dst=1:1 -sure -fx
IF EXIST tmpghost.txt DEL tmpghost.txt
 
Solution

mchadek

Distinguished
Aug 31, 2011
7
0
18,510
Thanks for the help. While waiting we ran across this one. I tried it earlier but must have left out some important parts of the script. A coworker found the problem and now it works.

for %%I IN (C:\Tempimg\*.gho) DO C:\ghost\ghost -Clone,Mode=PLoad,src=%%I:1,dst=1:1 -sure -fx