Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,835 of 68,980    |
|    John Stockton to LangerTom    |
|    Re: Problem with file copying in Batch    |
|    16 Nov 21 15:44:24    |
      From: dr.j.r.stockton@gmail.com              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"       @call Z-COPIER.BAT       @del Z-COPIER.BAT       @REM echo Xcopy /D /F /Y %1 ZZZ\%ZZZZZZ%\        Xcopy /D /F /Y %1 ZZZ\%ZZZZZZ%\       @echo.       @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.                     --        (c) John Stockton, near London, UK. Using Google Groups. |        Mail: J.R.""""""""@physics.org - or as Reply-To, if any. |              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca