Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Start directory for btm Batch files

Jun
11
0
I am using a batch file for cyclig backups. The btm (save) file is located in the directory, and from within the file I call another batchfile which does all the work.
Before updating to version 12, the directory, the command line window ended up in the directory, wherre the (save) btm file is located, and that directory was backed up.
With version 12, the command line window is opened in c:\, and the wrong directory would be saved.

What am I doing wrong ?

Thanks in advance !!!
 
Are you starting the batch files from an desktop icon? Is the properties
[start in c:\]


: -----Original Message-----
: From: Theschalker [mailto:]
: Sent: Friday, 30 September 2011 10:45 p.m.
: Subject: [T&T - Miscellaneous-t-3249] Start directory for btm
: Batch files
:
: I am using a batch file for cyclig backups. The btm (save)
: file is located in the directory, and from within the file I
: call another batchfile which does all the work.
: Before updating to version 12, the directory, the command
: line window ended up in the directory, wherre the (save) btm
: file is located, and that directory was backed up.
: With version 12, the command line window is opened in c:\,
: and the wrong directory would be saved.
:
: What am I doing wrong ?
:
: Thanks in advance !!!
 
Are you starting the batch files from an desktop icon? Is the properties
[start in c:\]

: -----Original Message-----
: From: Theschalker [mailto:]
: Sent: Friday, 30 September 2011 10:45 p.m.
: Subject: [T&T - Miscellaneous-t-3249] Start directory for btm
: Batch files
:
: I am using a batch file for cyclig backups. The btm (save)
: file is located in the directory, and from within the file I
: call another batchfile which does all the work.
: Before updating to version 12, the directory, the command
: line window ended up in the directory, wherre the (save) btm
: file is located, and that directory was backed up.
: With version 12, the command line window is opened in c:\,
: and the wrong directory would be saved.
:
: What am I doing wrong ?
:
: Thanks in advance !!!




Thanks for your reply.
No, I am not starting from an dsktop icon.
I am using different batch files in different directories, because I have to set a list of file types which I want to backup, plus the destination directory.
In the previous version, the batchfile started in the directory where it was stored.
Even without doing anything in the batchfile, the prompt is showing me where I am - and this is always c:\
 
Thanks for your reply.
No, I am not starting from an dsktop icon.
I am using different batch files in different directories, because I have to set a list of file types which I want to backup, plus the destination directory.
In the previous version, the batchfile started in the directory where it was stored.
Even without doing anything in the batchfile, the prompt is showing me where I am - and this is always c:\

How exactly are you starting it?

Do you have any relevant commands (CH, CHDIR, PUSHD, etc.) in your TCSTART.BTM file?
 
From: Theschalker
| No, I am not starting from an dsktop icon.
| I am using different batch files in different directories, because I
| have to set a list of file types which I want to backup, plus the
| destination directory.
| In the previous version, the batchfile started in the directory where
| it was stored.
| Even without doing anything in the batchfile, the prompt is showing
| me where I am - and this is always c:\

You need to show the method used to start the batch file, and the batch file itself, or at least its start.

BTW, if a batch file should always run in the directory in which it is located, the command below in the file will forice it:
cdd %@path[%_batchname]

However, if your backup procedure is similar in your various directories, you could create a single batch file which adopts some details based on either a parameter that is passed to the file, or on the default directory where it's running (NOT its own directory). That's what I do to back up my desktop to my laptop. The batch file is located on my path, so its name is all I need to start it; if no parameter is passed it backs up the directory tree of the default directory to the identically named tree on the other system.
--
HTH, Steve
 
Do you have a TCSTART file, and if so, what does it contain?

(Most of the time when users are winding up in the wrong directory it's
because of an errant CD / CDD in TCSTART.)

ok - here are the files:

cyclic_save.btm, which does the backup into rar-archives:
@echo off
@rem automatic cycling save
@rem copying old zip-files

@set dest_file=%backup_destination%%N_SAVE%.rar
@if exist %dest_file del %dest_file

@do i=%N_SAVE% to 1 by -1
@ set ori_file=%backup_destination%%i%.rar
@ set dest_file=%backup_destination%%@EVAL[%i+1]%.rar
@ echo %ori_file %dest_file
@ if exist %ori_file ren %ori_file %dest_file
@enddo

@rem copying latest zip file
@set ori_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]].rar
@set dest_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]]_1.rar
@if exist %ori_file copy %ori_file %dest_file

@if exist %ori_file del %ori_file
rem @call pkzip.exe -add -dir -excl=*.zip %ori_file %liste%
@call rar.exe a -r -x*.zip %ori_file %liste%

@exit




the following batch file is located ion the directory, which I want to backup:
@echo off

@rem set ori: location and filecore for zip-files
@rem set liste: list of file extensions to be saved
@rem set N_SAVE: number of copies of zip files to be kept
@set backup_destination=%Backup%Backup_test\Test_
@set liste=*.dat *.fis *.dvr *.doc *.dsf
@set N_SAVE=20
@call cyclic_save.btm
@exit



This last file is e.g. a "save.btm", and is stored in a directory. this directory where it is stored and it's subdirs should be backed up:
This has worked fo years with versions previous to the latest 12.
 
Are you starting the batch files from an desktop icon? Is the properties
[start in c:\]


: -----Original Message-----
: From: Theschalker [mailto:]
: Sent: Friday, 30 September 2011 10:45 p.m.
: Subject: [T&T - Miscellaneous-t-3249] Start directory for btm
: Batch files
:
: I am using a batch file for cyclig backups. The btm (save)
: file is located in the directory, and from within the file I
: call another batchfile which does all the work.
: Before updating to version 12, the directory, the command
: line window ended up in the directory, wherre the (save) btm
: file is located, and that directory was backed up.
: With version 12, the command line window is opened in c:\,
: and the wrong directory would be saved.
:
: What am I doing wrong ?
:
: Thanks in advance !!!


I think the problem can also be defined like this:
create a test.bat and a test.btm somewhere on the harddrive except in thr root dir, e.g. c:\temp.

All it should do is a <dir>

test.bat lists the contents of c:\temp
test.btm lists the contents of c:\
 
I am glad you discovered your issue. Since
this was a Support issue and not Tips & Techniques, it would have been
better placed in the Support forum.

You have quite a mixture of single and
dual percents. It makes reading your scripts difficult.

For instance:
set Backup=foo
set Backup_test=bar
set backup_destination=%Backup%Backup_test\Test_

[C:\] set backup_destination
backup_destination=fooBackup_test\Test_

Is that what you expected or did you
expect: foobar\Test_ ?

Your script is more complex than it
needs to be.
@set ori_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]].rar
@set dest_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]]_1.rar

If you don't include the trailing underscore
in backup_destination the above lines reduce to:
@set ori_file=%backup_destination.rar
@set dest_file=%backup_destination_1.rar

If you use the /E switch you don't have
to check if the files exist before you rename or copy. You can also
use the /Q switch to suppress any messages.

Your cyclic_save.btm then simplifies
to:

del /eq %backup_destination_%N_SAVE.rar
do i=%N_SAVE to 1 by -1 (ren /eq %backup_destination_%i.rar
%backup_destination_%@inc.rar)
ren /eq %backup_destination.rar %backup_destination_1.rar
rar.exe a -r -x*.zip %backup_destination.rar
%liste

-Scott



Quote:


Originally Posted by rconn

Do you have a TCSTART file, and if so,
what does it contain?

(Most of the time when users are winding up in the wrong directory it's
because of an errant CD / CDD in TCSTART.)
ok - here are the files:

cyclic_save.btm, which does the backup into rar-archives:
@echo off
@rem automatic cycling save
@rem copying old zip-files

@set dest_file=%backup_destination%%N_SAVE%.rar
@if exist %dest_file del %dest_file

@do i=%N_SAVE% to 1 by -1
@ set ori_file=%backup_destination%%i%.rar
@ set dest_file=%backup_destination%%@EVAL[%i+1]%.rar
@ echo %ori_file %dest_file
@ if exist %ori_file ren %ori_file %dest_file
@enddo

@rem copying latest zip file
@set ori_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]].rar
@set dest_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]]_1.rar
@if exist %ori_file copy %ori_file %dest_file

@if exist %ori_file del %ori_file
rem @call pkzip.exe -add -dir -excl=*.zip %ori_file %liste%
@call rar.exe a -r -x*.zip %ori_file %liste%

@exit




the following batch file is located ion the directory, which I want to
backup:
@echo off

@rem set ori: location and filecore for zip-files
@rem set liste: list of file extensions to be saved
@rem set N_SAVE: number of copies of zip files to be kept
@set backup_destination=%Backup%Backup_test\Test_
@set liste=*.dat *.fis *.dvr *.doc *.dsf
@set N_SAVE=20
@call cyclic_save.btm
@exit



This last file is e.g. a "save.btm", and is stored in a directory.
this directory where it is stored and it's subdirs should be backed up:
This has worked fo years with versions previous to the latest 12.
 
From: samintz
| Your script is more complex than it needs to be.
...
| Your cyclic_save.btm then simplifies to:
|
| del /eq %backup_destination_%N_SAVE.rar
| do i=%N_SAVE to 1 by -1 (ren /eq %backup_destination_%i.rar %backup_destination_%@inc.rar)
| ren /eq %backup_destination.rar %backup_destination_1.rar
| rar.exe a -r -x*.zip %backup_destination.rar %liste

For that matter, you could just cycle through backups 1 ... N, never renaming them, just use a separate control file in which you store the number of the last backup file used (or the next one to be used). You could format the control file as an .INI-file, and use the @iniread/@iniwrite functions; use a separate section for each directory tree to be backed up.
--
HTH, Steve
 
I am glad you discovered your issue. Since
this was a Support issue and not Tips & Techniques, it would have been
better placed in the Support forum.

You have quite a mixture of single and
dual percents. It makes reading your scripts difficult.

For instance:
set Backup=foo
set Backup_test=bar
set backup_destination=%Backup%Backup_test\Test_

[C:\] set backup_destination
backup_destination=fooBackup_test\Test_

Is that what you expected or did you
expect: foobar\Test_ ?

Your script is more complex than it
needs to be.
@set ori_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]].rar
@set dest_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]]_1.rar

If you don't include the trailing underscore
in backup_destination the above lines reduce to:
@set ori_file=%backup_destination.rar
@set dest_file=%backup_destination_1.rar

If you use the /E switch you don't have
to check if the files exist before you rename or copy. You can also
use the /Q switch to suppress any messages.

Your cyclic_save.btm then simplifies
to:

del /eq %backup_destination_%N_SAVE.rar
do i=%N_SAVE to 1 by -1 (ren /eq %backup_destination_%i.rar
%backup_destination_%@inc.rar)
ren /eq %backup_destination.rar %backup_destination_1.rar
rar.exe a -r -x*.zip %backup_destination.rar
%liste

-Scott



Quote:


Originally Posted by rconn

Do you have a TCSTART file, and if so,
what does it contain?

(Most of the time when users are winding up in the wrong directory it's
because of an errant CD / CDD in TCSTART.)
ok - here are the files:

cyclic_save.btm, which does the backup into rar-archives:
@echo off
@rem automatic cycling save
@rem copying old zip-files

@set dest_file=%backup_destination%%N_SAVE%.rar
@if exist %dest_file del %dest_file

@do i=%N_SAVE% to 1 by -1
@ set ori_file=%backup_destination%%i%.rar
@ set dest_file=%backup_destination%%@EVAL[%i+1]%.rar
@ echo %ori_file %dest_file
@ if exist %ori_file ren %ori_file %dest_file
@enddo

@rem copying latest zip file
@set ori_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]].rar
@set dest_file=%@SUBSTR[%backup_destination,0,%@EVAL[%@LEN[%backup_destination]-1]]_1.rar
@if exist %ori_file copy %ori_file %dest_file

@if exist %ori_file del %ori_file
rem @call pkzip.exe -add -dir -excl=*.zip %ori_file %liste%
@call rar.exe a -r -x*.zip %ori_file %liste%

@exit




the following batch file is located ion the directory, which I want to
backup:
@echo off

@rem set ori: location and filecore for zip-files
@rem set liste: list of file extensions to be saved
@rem set N_SAVE: number of copies of zip files to be kept
@set backup_destination=%Backup%Backup_test\Test_
@set liste=*.dat *.fis *.dvr *.doc *.dsf
@set N_SAVE=20
@call cyclic_save.btm
@exit



This last file is e.g. a "save.btm", and is stored in a directory.
this directory where it is stored and it's subdirs should be backed up:
This has worked fo years with versions previous to the latest 12.


Thanks a lot for your comments !
This was one of the first scripts I did, and it has worked in the way as ai expected.
Actually, the naming worked the way I wanted.

There is a backup directory, and for different projects, I use individual subdirectories. And the backup creates a new rar file, all existing ones are renamed with a counter increased by one.

But I will try your simplified version !

Again - many thanks to everyone here !
 
Back
Top