[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Re: Saving files in two drives
- Subject: Re: Saving files in two drives
- From: "Carl Distefano" cld@xxxxxxxx
- Date: Sun, 3 Apr 2016 15:32:27 -0400
Reply to note from "Carl Distefano" Sun, 28 Feb 2016
02:22:55 -0500
In my earlier post on this subject,
http://www.freelists.org/post/xywrite/Saving-files-in-two-drives,6
I outlined a batch file for saving (copying) a file to multiple
drives/directories. It contemplated that the target directories would be
hard-coded in the batch file itself. Here's a variant that allows you to
specify up to 8 target directories "on the fly", as arguments to the batch
file. (See usage in the batch file, below.) It also traps the error if the
target dir doesn't exist -- meaning that you can use the same canned command
line on all machines, regardless of directory structure.
:: COPYFILE.BAT [CLD rev.4/3/16]
@echo off
if %1! == ! (echo.
echo Usage:
echo COPYFILE.BAT filename target_dir1 target_dir2 . . . target_dir8^
echo.
pause
exit)
if not exist %1 exit
set fname=%1
shift
:a
if not %1! == ! (
if exist %1 copy/y %fname% %1 > nul
shift
goto a)
set fname=
exit
:: end
Of course, you can execute the batch file from with XyWrite, as part of a
SAve routine. In pseudo-code (omit line breaks; assumes that COPYFILE.BAT is
in the Path):
Xy4:
>BX saQ2
BX dos/nv/x/z /c cmd.exe /c COPYFILE.BAT dir1 dir2 ... dir8Q2
Xy3:
>BC saXC
BC dos /c cmd.exe /c COPYFILE.BAT dir1 dir2 ... dir8XC BC GT
--
Carl Distefano
cld@xxxxxxxx