I'm trying to run a backup program through a batch file command line; and what I'd like to do, if possible, is get the name of the folder the batch file is being run from and use that in the destination part of the command line for the backup program.
I'll try and illustrate to be more clear:
Batch file, backup.bat, is run from c:\work\stuff.
The command line for the backup program is: backup "SourceDirectory" "DestinationDirectory"
So I want "SourceDirectory" to be c:\work\stuff, and I want "DestinationDirectory" to be \\sever\otherDirectory\stuff.
I found the following code to retreive the name of the current directory:
:: get current directory
@SET cd=
@SET promp$=%prompt%
@PROMPT SET cd$Q$P
@CALL>%temp%.\setdir.bat
@
% do not delete this line %
@ECHO off
PROMPT %promp$%
FOR %%c IN (CALL DEL) DO %%c %temp%.\setdir.bat
This lets me use %cd% for the "SourceDirectory", but is there a way to strip out all but the actuall folder, in this case, "work", and append that the "DestinationDirectory", in this case, "\\sever\otherDirectory\"
I hope this makes sense any help would be greatly appreciated.