search old name in list

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
darioit
Posts: 230
Joined: 02 Aug 2010 05:25

search old name in list

#1 Post by darioit » 28 Mar 2011 08:39

Hi folks,

I have this new issue.

tree directory:
C:\a
C:\b
C:\c
a lot of file arrive on directory c:\a

every 5 minutes start a bat that do this operation:

1 ) move file from a to b (move c:\a\* c:\b)
2) other process..................
3) move file from b to c (move c:\b\* c:\c)

sometimes some process in step 2 terminate in error, and in directory c:\b the file remain forever.

I like to do write this code for check:

dir /b c:\b\* > list_new.txt
move c:\a\* c:\b\
dir /b c:\b > list.txt

new code to write
for every line in list_new.txt check if already exist in list.txt and send a warning

Regards
Last edited by darioit on 30 Nov 2011 05:13, edited 1 time in total.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: search old name in list

#2 Post by aGerman » 28 Mar 2011 14:15

FC will do that for you.

Regards
aGerman

darioit
Posts: 230
Joined: 02 Aug 2010 05:25

Re: search old name in list

#3 Post by darioit » 29 Mar 2011 02:03

Thanks aGerman, but I don't need to compare the content of the file, but only the name.

I wrote this code and it seems works fine, any suggestion to improve the code?

Code: Select all

@echo off
set trovato=
del C:\list_old.txt
ren C:\list.txt list_old.txt
dir /b C:\b > C:\list.txt
for /f %%i in ('dir /b c:\b') do findstr /b %%i C:\list_old.txt > nul && set trovato=%%i && call :errore

goto:eof

:errore
echo routine errore %trovato%


Regards
Dario

Post Reply