On Friday, 12 November 2021 at 00:46:22 UTC, LangerTom wrote:
> I hope that I have understood you correctly. If so the following snippet
> shoud show you a solution for your problem. It works with 4 sub
> routines, 3 of them used internally only, for an intermediate step to
> process the name of the target directory. This routines use
> call-by-reference method for returning results like PASCAL.
The need is to truncate a filename immediately
before/after its final backslash.
Thank you for your efforts. Your code uses batch
language features which I know nothing about,
and I don't want to have code which I cannot read.
A year and a half ago, I wrote code calling JScript
from Batch to do string editing using RegExps; it
is in this newsgroup. I could not get it to what I need;
I think I know why - I need a RegExp containing
parentheses within a Batch FOR loop, and as then
written that defeated the parser.
So I tried with MiniTrue, hit the same situation,
but found a satisfactory work-round. The following
code is a bit voluble. TRANSFER.BAT can be constructed
by echoing the necessary lines before the loop which uses it.
@echo Starting TRANSFER.BAT %1 JRS 2021-11-16+
@echo %1 > Z-COPIER.BAT
@MTR -n -b- Z-COPIER.BAT (.*)(\\.*) = "set ZZZZZZ=\1"
@REM echo Xcopy /D /F /Y %1 ZZZ\%ZZZZZZ%\
Xcopy /D /F /Y %1 ZZZ\%ZZZZZZ%\
@REM The End of TRANSFER.BAT
& in the main file, with ZZZZ.TXT being the list
of image filenames :
@FOR /F "eol=; tokens=*" %%J IN (ZZZ\ZZZZ.TXT) DO @(
call TRANSFER.BAT %%J
which I'm almost certain can be pruned, but not tonight.
The essential is to execute the code in TRANSFER.BAT
without it being lexically in the FOR loop.
From what you wrote, I think there must be a better way
of returning the result from MTR.
As is, I think the speed is (unimportantly) limited
by screen-writing time.