what operating system? MS-Windows? use FindFirstFile() and FindNextFile() to get a list of all the files in dir A, store the filenames in a string array. Then use the same functions to get the files in directory B. For each file in B search the array of filenames you created from directory A, if found the delete the file.
Ancient Dragon
Retired & Loving It
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Thanks. I use Ubuntu and Windows. I'm looking for a shell script that does this. But I'll try what you're saying as well. Thanks.
Shell scripting is much easier. But this is not the forum for that. There is a UNIX support forum for scripting in daniweb. But you could try this.
#!/bin/bash
pathA='/blah/blah/blah/'
pathB='/blah/blah/blah/blah/'
ext="deb"
for file in $(ls "$pathA"); do
#
# Only process DEB files.
#
file_ext=${file##*.}
case $file_ext in
deb | DEB )
if [ -e "$pathB$file" ]; then
echo deleting "$pathB$file"
rm -f "$pathB$file"
fi
esac
done
WolfPack
Postaholic
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115