home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 42,140 of 42,547   
   Zaidy036 to Neil   
   Re: List of NOT duplicate files   
   13 Mar 23 16:14:58   
   
   XPost: alt.comp.os.windows-10   
   From: Zaidy036@air.isp.spam   
      
   On 3/13/2023 1:19 PM, Neil wrote:   
   > On 3/13/2023 4:06 PM, Mr. Man-wai Chang wrote:   
   >> On 3/13/2023 3:08 AM, Neil wrote:   
   >>>   
   >>> List of NOT duplicate files   
   >>>   
   >>   
   >> "NOT duplicate"" = Unique? :)   
   >   
   > It doesn't really matter what the contents of the files are.   
   >   
   > I only brought up the contents being different because a dumb move wouldn't   
   > work because that would overwrite files of the same name in A with the new   
   > contents of another file of the same name from B.   
   >   
   > A is the master folder.   
   >   
   > B is just the new files (some of which may have the same name and hence   
   > would be discarded).   
   >   
   > I should also be clear the copy (or move) isn't the problem because Windows   
   > already won't copy over the file in A if it has the same name as in B.   
   >   
   > What I'm after is the _list_ of files that were copied (or moved) over from   
   > B to A (those are all going to be file names which were not in A prior).   
   >   
   > Kind of like this pseudish code snip   
   > cd B   
   > for %i in (*.txt) do if not exist ..\a\%i copy %i ..\A\   
   > echo %i >> list_of_file_names_in_b_not_in_a.txt   
   >   
   > I don't even need to do the copy/move because that's the easy part.   
   > The hard part for me is getting a list of file names in B not already in A.   
   A list of file names in a folder:   
   DIR /B  > X:\FolderA.txt   
   where X: is a full path and not required if same folder as folderA   
      
   So make a batch:   
   1. Make FolderA.txt   
   2. Make FolderB.txt   
   3. FOR /f %%A in ('DIR /A:D /B "FolderB.txt" ^| FIND /V /C ""') DO SET   
   cnt=%%A   
   4. Make a loop:   
       FOR /L %%f IN (1,1,%cnt%) DO (   
       SET /P _Fname=%\!_Fname! echo !_Fname!>> X:\FolderC.txt   
       MORE +1 FolderB.txt   
       )   
   FolderC will contain file names from FolderB that are also in FolderA   
      
   --- 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