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,827 of 68,980   
   John Stockton to All   
   Re: Problem with file copying in Batch   
   07 Nov 21 03:52:13   
   
   From: dr.j.r.stockton@gmail.com   
      
   On Saturday, 6 November 2021 at 12:46:34 UTC, JJ wrote:   
   > On Thu, 4 Nov 2021 15:30:11 -0700 (PDT), John Stockton wrote:    
   > > In this code, the echo lines are merely for debugging    
   > >    
   > > @echo FOR /F "eol=; tokens=*" %%J IN (ZZZ\ZZZZ.TXT) DO (    
   > > FOR /F "eol=; tokens=*" %%J IN (ZZZ\ZZZZ.TXT) DO (    
   > > @echo TRYING : Xcopy /F %%J ZZZ\%%J    
   > > Xcopy /F %%J ZZZ\%%J    
   > > @echo.    
   > > )    
   > >    
   > > 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?   
   > You're basically copying one file at a time based on a list of file names    
   > with relative path. Use `copy /y` instead of using the XCOPY program. XCOPY    
   > is intended for recursive copy.   
      
   I did not understand Mokomoji - too many unnecessary alterations.   
      
   I copied that loop, with alteration, from an existing application using Xcopy   
   /D/F /Y (Backup or Distribute, to a USB memory stick, for which I really   
   wanted the Xcopy /D effect since generally most files will not need   
   updating).  In this case, the /D    
   would be beneficial, but only slightly so.  The list of    
   files will sometimes have duplicates.  But this code will mostly run on a PC   
   with C: being a SSD, so occasionally recopying a file over itself would not   
   matter.   
      
   I could sort the list using SORT, and when copying put the name of the current   
   file into an environment variable, and copy only if the next request was for a   
   different name; but them I would not see the names on the screen in their   
   "natural" order ...   
      
   Fx : test :  but NO!  XCOPY, unlike COPY,  creates directories as needed.   
      
   I had not said that the files to be copied are *ALL* in subdirectories of   
   \MYSLIDES, and there are currently 58 of those subdirectories have   
   subdirectories of their own - e.g.    
      
         C:\MYSLIDES\01-I\22.JPG   
         C:\MYSLIDES\SCANS\PRESFRM1.PNG   
      
         C:\MYSLIDES\MONONEGS\06\X5Y7.JPG   
         C:\MYSLIDES\SCANS\OVEN\0102.PNG   
      
   I could use  DIR /S /B /A:D to make a list for MKDIR to create all   
   subdirectories that might be needed, but that is inelegant.   
      
   In the meanwhile,  I'll try long runs of the script only when I have another   
   use for the hand which is not busy typing F, e.g. by eating sandwiches with it.   
      
   Might ROBOCOPY be better?   
      
   --    
     (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