Help with a batch file

  • Thread starter cornedbeef007-groups
  • Start date
C

cornedbeef007-groups

I have an application to image my hard disk partitions. I can run the
application from commandline, specifying, among othjer options, the
partition to target, and the location and name of the output image
file.

Here's what I want to do.

List all the existing image files in the output path.
They will be in the format C_Drive-001.tbi, and C_Drive-002.tbi etc.

I want to find the seqence number of the last file, and use it to
generate the filename for the next file. In this case it will be
C_Drive-003.tbi.

On the succesfull completion of the image, then delete the oldest
image file, leaving 2 files there.

I will then run this script as a scheduled task to regularly image my
system.

So I need to know, how to parse the output of a DIR C_Drive*.tbi /o-D /
b to find the seqence number of the current image file, and then pass
that to the next line which executes the image program.

Any ideas?

Thanks.
 
T

thanatoid

(e-mail address removed) wrote in
ups.com:
I have an application to image my hard disk partitions. I
can run the application from commandline, specifying, among
othjer options, the partition to target, and the location
and name of the output image file.

Here's what I want to do.

List all the existing image files in the output path.
They will be in the format C_Drive-001.tbi, and
C_Drive-002.tbi etc.

I want to find the seqence number of the last file, and use
it to generate the filename for the next file. In this case
it will be C_Drive-003.tbi.

On the succesfull completion of the image, then delete the
oldest image file, leaving 2 files there.

I will then run this script as a scheduled task to
regularly image my system.

So I need to know, how to parse the output of a DIR
C_Drive*.tbi /o-D / b to find the seqence number of the
current image file, and then pass that to the next line
which executes the image program.

First thing I am curious about, why try such a bizarre manner of
imaging - while using an Acronis image file extension to boot,
so to speak?

The second is, WHY do all that imaging? Too much free drive
space getting on your nerves? Imaging drives is not an efficient
manner of backing up data. Partitioning and organizing things
is. Why not just get a regular scheduled backup happening and
image C: only when it is necessary?

Which made me think that you might be able to find an old DOS
program which can be scheduled/automated and will run from a
command line within XP. Or something like that. If you really
want to do what you described. But C: should only contain the OS
and programs, and not necessarily even ALL programs. Therefore
aside from basic clean-up of junk and maintenance, it does not
need to be imaged unless you make significant changes to your
system.
 
C

cornedbeef007-groups

(e-mail address removed) wrote inups.com:












First thing I am curious about, why try such a bizarre manner of
imaging - while using an Acronis image file extension to boot,
so to speak?

The second is, WHY do all that imaging? Too much free drive
space getting on your nerves? Imaging drives is not an efficient
manner of backing up data. Partitioning and organizing things
is. Why not just get a regular scheduled backup happening and
image C: only when it is necessary?

Which made me think that you might be able to find an old DOS
program which can be scheduled/automated and will run from a
command line within XP. Or something like that. If you really
want to do what you described. But C: should only contain the OS
and programs, and not necessarily even ALL programs. Therefore
aside from basic clean-up of junk and maintenance, it does not
need to be imaged unless you make significant changes to your
system.- Hide quoted text -

- Show quoted text -

After all of your rant, do you have any suggestions on my batch
file......?

I thought not!
If you can't help, $!@#$ OFF!
 
H

HeyBub

After all of your rant, do you have any suggestions on my batch
file......?

I thought not!
If you can't help, $!@#$ OFF!

Several million 1/4" drill bits are sold each year. But none of the people
who bought a /4" drill bit actually WANTED a 1/4" drill bit.

What they wanted was a 1/4" HOLE.

Attempting to divine what you really want from trace bits you've scattered
about is a useful technique to provide you with a solution to your original
problem.

It is unlikely that you really want a batch file (unless you collect them
and trade them with your friends).
 
T

thanatoid

(e-mail address removed) wrote in
oups.com:

After all of your rant, do you have any suggestions on my
batch file......?

I thought not!
If you can't help, $!@#$ OFF!

Yes Mr. Goolper, Sir!
And thank you for not top-posting, but NO thanks for not
snipping!
 
R

Richard.Williams.20

I have an application to image my hard disk partitions. I can run the
application from commandline, specifying, among othjer options, the
partition to target, and the location and name of the output image
file.

Here's what I want to do.

List all the existing image files in the output path.
They will be in the format C_Drive-001.tbi, and C_Drive-002.tbi etc.

I want to find the seqence number of the last file, and use it to
generate the filename for the next file. In this case it will be
C_Drive-003.tbi.

On the succesfull completion of the image, then delete the oldest
image file, leaving 2 files there.

I will then run this script as a scheduled task to regularly image my
system.

So I need to know, how to parse the output of a DIR C_Drive*.tbi /o-D /
b to find the seqence number of the current image file, and then pass
that to the next line which executes the image program.

Any ideas?

Thanks.




Here is a script that will do that.

Assumptions
-----------
- All the image files C_Drive*.tbi are in folder "C:/images/storage
folder"
- The command-line (that's good) application to create the image takes
the following format.
/path/to/imagetool.exe "/path/to/output file"




# Script LatestImage.txt
var str imagelist, lastimage, firstimage, sequence
var int seqnum
# Go to folder where images are stored.
cd "C:/images/storage folder" # ENTER CORRECT PATH HERE
# Collect a list of images already in the folder.
lf -n "C_Drive*.tbi" "." > $imagelist
# Files are listed by name, so the first file is earliest image.
# And, the last file is the latest image.
lex -p "l" $imagelist > $firstimage
lex -p "1" $imagelist > $lastimage
# NOTE "1" in the first lex is ONE. "l" In the second lex is ELL.
echo -e "DEBUG: First image is " $firstimage ", Last image is "
$lastimage
# Get the sequence number from the last image.
# It is before the last . and after the last dash
stex "]^.^l" $lastimage > $sequence ; stex "^-^l]" $lastimage > null
# Convert the sequence to an integer number.
set $seqnum = makeint(str($sequence))
# Increment $seqnum
set $seqnum = $seqnum + 1
# Put $seqnum in string format
set $sequence = makestr(int($seqnum))
while ( { chen $sequence } < 3 )
set $sequence = "0"+$sequence

# Run the image tool.
echo -e "DEBUG: Creating next image sequence " $sequence
system ("\""+"/path/to/imagetool.exe"+"\"") ("\""+"/path/to/output
file/"+"C_Drive-"+$sequence+".tbi"+"\"")
# Delete the first image.
system del ("\""+$firstimage+"\"")






Script is in biterscripting ( http://www.biterscripting.com ). To try,
save the script in file C:/Scripts/LatestImage.txt, then execute in
biterscripting this command.


script "C:/Scripts/LatestImage.txt"



I have not tested the script since I don't have the image tool. Test
it first by commenting out (#) the 'system delete' command.
 
C

cornedbeef007-groups

I have an application to image my hard disk partitions. I can run the
application from commandline, specifying, among othjer options, the
partition to target, and the location and name of the output image
file.
Here's what I want to do.
List all the existing image files in the output path.
They will be in the format C_Drive-001.tbi, and C_Drive-002.tbi etc.
I want to find the seqence number of the last file, and use it to
generate the filename for the next file. In this case it will be
C_Drive-003.tbi.
On the succesfull completion of the image, then delete the oldest
image file, leaving 2 files there.
I will then run this script as a scheduled task to regularly image my
system.
So I need to know, how to parse the output of a DIR C_Drive*.tbi /o-D /
b to find the seqence number of the current image file, and then pass
that to the next line which executes the image program.
Any ideas?

Here is a script that will do that.

Assumptions
-----------
- All the image files C_Drive*.tbi are in folder "C:/images/storage
folder"
- The command-line (that's good) application to create the image takes
the following format.
        /path/to/imagetool.exe "/path/to/output file"

# Script LatestImage.txt
var str imagelist, lastimage, firstimage, sequence
var int seqnum
# Go to folder where images are stored.
cd "C:/images/storage folder"    # ENTER CORRECT PATH HERE
# Collect a list of images already in the folder.
lf -n "C_Drive*.tbi" "." > $imagelist
# Files are listed by name, so the first file is earliest image.
# And, the last file is the latest image.
lex -p "l" $imagelist > $firstimage
lex -p "1" $imagelist > $lastimage
# NOTE "1" in the first lex is ONE. "l" In the second lex is ELL.
echo -e "DEBUG: First image is " $firstimage ", Last image is "
$lastimage
# Get the sequence number from the last image.
# It is before the last . and after the last dash
stex "]^.^l" $lastimage > $sequence ; stex "^-^l]" $lastimage > null
# Convert the sequence to an integer number.
set $seqnum = makeint(str($sequence))
# Increment $seqnum
set $seqnum = $seqnum + 1
# Put $seqnum in string format
set $sequence = makestr(int($seqnum))
while ( { chen $sequence } < 3 )
    set $sequence = "0"+$sequence

# Run the image tool.
echo -e "DEBUG: Creating next image sequence " $sequence
system ("\""+"/path/to/imagetool.exe"+"\"") ("\""+"/path/to/output
file/"+"C_Drive-"+$sequence+".tbi"+"\"")
# Delete the first image.
system del ("\""+$firstimage+"\"")

Script is in biterscripting (http://www.biterscripting.com). To try,
save the script in file C:/Scripts/LatestImage.txt, then execute in
biterscripting this command.

script "C:/Scripts/LatestImage.txt"

I have not tested the script since I don't have the image tool. Test
it first by commenting out (#) the 'system delete' command.- Hide quoted text -

- Show quoted text -

Thanks Richard,
Exactly what I need. Take two stars from petty cash!
 
R

Richard.Williams.20

Thanks Richard,
Exactly what I need. Take two stars from petty cash!- Hide quoted text -

- Show quoted text -



You are welcome. Always nice to hear back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top