Find duplicate file names between two folders

Ever need to check whether files in one folder exist in another folder? Here’s a quick bash script to do just that…

for file in * ; do [ -f ../images/$file ] && echo $file ; done

So, assuming you want to check that any files in your current folder already exist in the ../images folder, this bash script will print the names of any duplicate files.

All it’s doing is iterating over the file in your current folder, checking to see if that file exists in the ../images folder, and if ti does, print the file name.

Nice.

Advertisements

2 thoughts on “Find duplicate file names between two folders

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s