home bbs files messages ]

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,834 of 68,980   
   LangerTom to All   
   Re: Problem with file copying in Batch   
   12 Nov 21 01:46:21   
   
   From: hobby.tl@langer-online.net.invalid   
      
   Am 11.11.2021 um 19:03 schrieb John Stockton:   
   > On Sunday, 7 November 2021 at 19:56:56 UTC, LangerTom wrote:   
   >> Am 04.11.2021 um 23:30 schrieb John Stockton:   
   >   
   >   
   >>> That works, except that every time Xcopy is called, I get, on-screen,   
   >>>   
   >>> "Does C:\MYSLIDES\ZZZ\33-xxxiii\11.jpg specify a file name   
   >>> or directory name on the target   
   >>> (F = file, D = directory)?"   
   >>>   
   >>> An answer of F works, but I don't want to be asked; there may be over 100   
   calls. I've tried XCOPY /?, but cannot recognise a suitable option.   
   >>>   
   >>> What should I do?   
   >>>   
   >> If I remember correctly you should add a trailing back slash to the   
   >> target. This tells xcopy to copy files to a target directory.   
   >>   
   >> xcopy /f %%J ZZZ\%%J\   
   >>   
   >> (not tested)   
   >   
   > I think you have the right idea, but adjustment is needed.   
   > A typical command line is   
   >       Xcopy /D /F /Y 37-xxxvii\20.jpg ZZZ\37-xxxvii\20.jpg   
   > and I think I want to remove the trailing   20.jpg - but another typical   
   line is   
   >       Xcopy /D /F /Y scans\oven\1516.png ZZZ\scans\oven\1516.png   
   > with more sub-folders - I need to remove the characters after the LAST \   
   character.   
   > The extension part will be three characters, but there could be any number   
   of characters in the file name before the extension.   
   >   
   > I don't know how to do that in reasonably brief pure batch.   
   >   
   > Might    %~pI      be used? - seems not;   
   >       Xcopy /D /F /Y %%J ZZZ\%%~pJ  copies to C:\MYSLIDES\ZZZ\   
   YSLIDES\37-XXXVII\20.JPG  !!   
   >   
   > I had thought, as I said, to automate typing all those F responses by piping   
   in a file full of Fs - no good.   
   >   
   > But it is possible to depress the F key when first asked for it, keep it   
   down while all the XCOPY output scrolls rapidly upwards, and release it when a   
   briskly-flowing line of Fs appears.  Since this batch program will almost   
   always be started by hand,    
   and finishes directly after the copying, that is good enough.  The repeat rate   
   of the F key is much faster than that of my finger-pressing.  If I release the   
   F key too soon, F.BAT will maybe run (it starts File Explorer), but commands   
   starting with    
   multiple-F are not implemented here.   
   >   
   >   
   >   
   > I have fixed the MiniTrue -o pipe/redirect error difficulty : I copy the   
   input file, then in multiple MiniTrue passes on the copy, I : (0) prepend OMIT   
   to all lines, (1 to N) alter OMIT to STET on lines wanted for various reasons,   
   (N+1) remove the OMIT    
   lines and the STET words.  STET is logically redundant, but it helps when   
   visually checking.   
   >   
   > The line   copy A+B+C A   is not a good way to extend file A.   
   >   
   > So : all is well enough with the image file copying, maybe.   
   >   
   > It only remains to STET the  lines and to remove, finally, all but the   
   first of a set of consecutive such lines somehow.   
   > And to adjust the dispositions of 
    and/or
      in the source file.       >                     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.              HTH Thomas                                   set "J=C:\MYSLIDES\33-xxxiii\11.jpg"       call :GetPathInfo "%J%" TargetPath       echo xopy /D /F /Y %J% %TargetPath%       REM xopy /D /F /Y %%J %TargetPath%              echo %SourcePath% %TargetPath%       pause       goto :eof                     REM **** sub routines *****              :GetPathInfo        call :GetSourcePath "%~1" SourcePath        call :GetSourceDirname "%sourcePath%" DirName        call :GetTargetPAth TargetPath        goto :EOF                     :GetSourcePath        Set "Oldpath=%cd%"        cd /d "%~1\.."        set "%~2=%cd%"        cd /d "%oldpath%       goto :EOF                     :GetSourceDirName        Set "%2=%~n1"       goto :EOF                     :GetTargetPath        Set "oldpath=%cd%"        cd /d "%SourcePath%\.."        Set "%~1=%cd%\ZZZ\%Dirname%\"        cd /d "%oldPath%"       goto :EOF                                                 --- 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