Compare folders mac os

Compare Two Directories Contents on a Mac Using diff

If you want to see the difference between two folders on a Mac, or compare two directories contents, you can easily do so with the help of the powerful diff command.

This tutorial will show you how to compare two directories, and the contents of those directories, by using the Terminal. This command line approach will output a file containing the precise differences shown between two target folders.

To achieve this comparison, we’ll use the command line tool ‘diff’, diff is available on all Macs, along with linux and other unix operating systems, so this is effectively a cross-platform solution for comparing directories. Diff is quite simple to use for easily comparing the contents of any two directories, just follow along by using syntax detailed below.

How to Compare Contents of Two Directories with diff

To get started, launch the Terminal in Mac OS (found in /Applications/Utilities/) and then use the following command syntax:

diff -rq directory1 directory2

Hit return when you have specified the appropriate directories to compare. This executes the diff command comparing directory1 and directory2 (if you have a folder with a space in the file name, just put it in quotes like so: “folder one”). We are using the -rq flag because -r means it is recursive to include subdirectories, and -q simplifies the command output to only the differences shown.

Sample output of the command may look like the following:

$diff -rq directory1 directory2

Only in directory1: example221.txt

Only in directory1: SuperSecretDifferentFile.rtf

Only in directory2: AmazingScript.py

Only in directory2: MyFavoriteSong.mp3

Only in directory2: MyFavoriteSpecialMovie.mp4

You can also go a step further and redirect the output of that command to a file, let’s say it’s named differences.txt:

diff -rq directory1 directory2 >> differences.txt

Here’s an example and how the actual printout will look. Let’s say w’re comparing folders named “old music” and “new music”, and we want the command output showing the difference between those two directories in the file named “musicfolders.txt” then the following command syntax would be used:

diff -rq «old music» «new music» >> musicfolders.txt

Now look in the present working directory for the file you just created via outputting the diff command, in this case the file is musicfolders.txt and the contents can be viewed in any text editor, command line or otherwise. Opening the text file you’ll see something like this:

Only in old music: song1.mp3
Only in old music: song2.mp3
Only in old music: song3.mp3
Only in new music: instrumental1.mp3
Only in new music: instrumental1.mp3

If you want to view the file from the command line, try:

Otherwise just navigate to the containing directory and open it in your favorite text editor.

If you’d prefer not to create a text file with the changes, just leave off the output redirection of the command. You might want to pipe the output to something like ‘more’ to make it easier to scan though:

diff -rq «old music» «new music» | more

The diff command is quite powerful and there are many other options available with it, use the man diff command to get full details on how to use diff as well as the myriad features available.

It’s worth mentioning again that this command will work in Mac OS X – all versions – as well as most Unix based OS’s.

Источник

Compare & Sync Folders 4+

Backup, two way synchronize

VADIM ZYBIN

    • 2.6 • 36 Ratings
    • Free
    • Offers In-App Purchases
Читайте также:  Стартовая загрузка windows 10

Screenshots

Description

Compare & Sync Folders is an easy-to-use app for beginners, has the ability to fine-tune synchronization settings for the most exacting professionals.

The app can synchronize multiple pairs of folders at the same time. Using convenient preview mode you can view the changes before sync and change the operation with files, if required. The Compare & Sync Folders also provides robust tools to filter files and folders so that you sync exactly what you want.

Compare & Sync Folders is perfect for backups to external storage devices including:
USB, memory cards, disks on remote computers within your network, folders on Cloud services (Dropbox, etc.) With each re-backup, the app finds and copies only new files and new file versions, thereby reducing backup time and extending the life of your storage devices.

Do you have terabytes (TB) of data to sync? No problem! Compare & Sync Folders has been optimized to work with extremely large number of files. Sit back and relax, your data is being automatically synced!

The app supports bidirectional synchronization!

Please, contact us with any questions, we are very happy to provide quick answers and make the app better for you.

Install another our great product, VPN Server Configurator, and you can synchronize folders on a remote Mac from anywhere in the world!
Install the Sync Folders Pro app, and you can synchronize folders «on the fly» using our REAL TIME SYNC technology or by schedule!
Learn more at www.greenworldsoft.com.

FOR BEGINNERS
— Select two folders to synchronize.
— Click «Sync» button.

FOR PROFESSIONALS
— 9 modes of synchronization. Real bidirectional synchronization. Tracking deletions, additions, changes in synchronized folders.
— 6 file comparison modes allow to synchronize files on the storage devices with different file systems (OS X, FAT32, etc.)
— 9 modes of file operations. Convenient Preview mode. Change the operation with files before sync, if required.
— 5 search modes for items of the Preview table (by name, path, name & path, …).
— 11 filter modes for items of the Preview table (Missing&Diffs, Missing, Diffs, Equal, …).
— Synchronization over the network. The ability to automatically connect network folders before synchronization.
— Protection for unauthorized disconnect storage devices (folders) during synchronization.
— Saving the last/all versions of files to be deleted. Using this mode, you can always restore deleted files, even if folders have synchronized several times.
— Compare files using QuickLook or «Line by Line» comparison before sync.
— Shows selected files in the Finder.app
— Opens selected files in the default app.
— Execution of file operations for the selected items of the Preview table.
— Copy the selected items (Missing, Diffs, …) of the Preview table into the third folder.
— Resolving the file versions conflict.
— Each pairs of folders shows when synchronization was done the last time.
— The synchronization process is logged.
— Save / Load the program settings to a file.
— You can transform the app to the convenient file manager using powerful filters for files and folders and writing your own copy script.
— Synchronization of subfolder attributes.
— Writing your own copy scripts, for example:
— Copy all non-synced files to selected folder before copying.
— Copying files using Unix commands: cp, rsync .

The main difference from the similar apps on the App Store:
— Real bidirectional synchronization. Tracking deletions, additions, changes in synchronized folders.
— Faster synchronization of the large folders.

Источник

How to use the macOS command line to compare two folders’ contents in Terminal

Have you ever wanted a quick way to compare two directories (folders), in order to see which files may differ between the two? There are third-party GUI tools as well, but there’s actually a free folder comparison tool built into every Mac—it just requires a quick trip to Terminal to put it to use. The program is called diff , and it’s quite simple to use.

Читайте также:  Linux container что это

Launch Terminal (in Applications > Utilities), and then use the cd command to change to the directory containing the folders you’d like to compare. (The folders can be located anywhere, of course, but it’s easiest if they’re in the same folder.). Once there, just run this command:

This is a pretty simple command, with two command-line switches ( -rq ).

  • The r tells diff to look at each directory recursively, including subdirectories.
  • The q switch sets diff in brief mode. If we didn’t set brief mode, diff would not only tell you which files are different between the two folders, but also show the actual line-by-line differences for any text files that exist in both locations but are not identical. Given that we’re just interested in comparing the folders’ contents, we don’t need that level of detail, so we’ll use brief mode to suppress it.

And that’s all there is to it. Here’s how it looks in action ( comments_new and comments_old are the two folders that I’m comparing):

Obviously, this is a simplistic example, but it works just as well on a large folder with hundreds of files. If you want to do more with diff , of course, it’s capable of much more than just simple folder comparisons; type man diff to read about its full capabilities.

Источник

What directory comparison tools can I use on OS X?

I am looking for a tool that is able to compare directories, not only files. Also it is important to be able to call the tool from the command line.

It would be great to have a free tool, if not free please specify the price.

15 Answers 15

For all the googlers. check out Beyond Compare it rules. Costs 30$ or 50$ for Pro version.

FileMerge (free), shipped with Xcode, offers a directory view.
A command line version is available through the Terminal application opendiff.

Here’s how you can compare two directories with FileMerge:

  1. ⌘+space, type in «FileMerge» and open it.
  2. Click the «left» button and choose the folder you would like to move items FROM. (The «old» folder)
  3. Click the «right» button and choose the folder you would like to move items TO. («new» folder) and click «Compare» button
  4. In the right panel, choose to exclude: «identical» and «Changed right». This way you will only see files which are missing in the «new» folder and ignore files your may have added in the «new» folder.
  5. Move files manually in Finder or let FileMerge do it, by choosing an option in the «Merge» dropdown in the right panel.

Built-in utility for macOS and Linux

If you don’t mind using the terminal, the diff command can compare directories.
This utility is also available in most Linux distributions.

-r indicates recurse through subdirectories, and -q gives brief output (i.e. don’t show the actual diffs, just note what files/dirs are different).

Other useful options are:
-s report identical files,
-i ignore case in file contents,
—ignore-file-name-case ignore case when comparing file names.

If you want to avoid warnings (mostly usefulness warnings) about differences in the .DS_Store files, then use:

Diffmerge should meet all your requirements.

Another neat tool to achieve this is rsync , as described on Unix & Linux StackExchange. To compare two folders you can do:

And if you are concerned about corrupt files / bit rot there is also the -c option to compare file checksums. This takes much more time of course as all files are checked in detail.

You should try the powerful open-source software meld. The Mac version can be found at Meld for OSX. It supports both directory and file comparison and works great under Mac.

I was told to improve this answer and explain why meld is good. Generally speaking, Meld is a full feature comparison software mainly used in GNOME. It is better than a lot of software listed here because

  1. it is free and open source. So you do not need to worry about the fee or security
  2. if not more powerful, it is as sophisticated as a lot of software which asks you a lot of money
  3. it is user-friendly and does not involve complex configuration or typing command in the terminal. You should be able to use it immediately once you install it.
Читайте также:  Docker compose linux update

The part that it is not as good might be that it is developed under GTK. So sometimes it does not feel like nature MAC programs. Besides, the old MAC versions were a little buggy. But the latest one 3.19.2 that I am currently using works great and I have never met an issue.

Источник

Compare & Sync Folders 4+

Backup, two way synchronize

VADIM ZYBIN

    • 1,8 • Оценок: 4
    • Бесплатно
    • Включает встроенные покупки

Снимки экрана

Описание

Compare & Sync Folders — это простое в использовании приложение для начинающих, имеет возможность тонкой настройки параметров синхронизации для самых взыскательных профессионалов.

Приложение может одновременно синхронизировать несколько пар папок. Используя удобный режим предварительного просмотра, вы можете просмотреть изменения до синхронизации и изменить операцию с файлами, если это необходимо. Compare & Sync Folders предоставляет надежные инструменты для фильтрации файлов и папок, чтобы Вы синхронизировали именно то, что хотите.

Compare & Sync Folders идеально подходит для резервного копирования на внешние носители информации, включая: USB, карты памяти, диски на удаленных компьютерах в вашей сети, папки на Cloud сервисах (Dropbox, и т.д.) При каждом повторном резервном копировании приложение находит и копирует только новые файлы и новые версии файлов, тем самым сокращая время резервного копирования и продлевая срок службы ваших дисков.

У Вас есть терабайт (ТБ) данных для синхронизации? Нет проблем! Compare & Sync Folders оптимизировано для работы с чрезвычайно большим количеством файлов.

Приложение поддерживает двунаправленную синхронизацию!

Пожалуйста, обращайтесь к нам с любыми вопросами, мы очень рады предоставить быстрые ответы и сделать приложение лучше для Вас.

Установите еще один из наших продуктов, VPN Server Configurator, и вы сможете синхронизировать папки на удаленном компьютере из ЛЮБОЙ ТОЧКИ МИРА!
Установите приложение Sync Folders Pro, и вы сможете синхронизировать папки «на лету» с использованием нашей технологии REAL TIME SYNC или по расписанию!
Узнайте больше на www.greenworldsoft.com.

ДЛЯ НАЧИНАЮЩИХ
— Выберите две папки для синхронизации.
— Нажмите кнопку «Синхронизировать».

ДЛЯ ПРОФЕССИОНАЛОВ
— 9 режимов синхронизации. Имеет режим двунаправленной синхронизации. Отслеживание удалений, добавлений, изменений в синхронизируемых папках.
— 6 режимов сравнения файлов позволяют синхронизировать файлы на дисках с разными файловыми системами (OS X, FAT32, т.д.).
— 9 режимов файловых операций. Режим предварительного просмотра. Возможность изменять операции с файлами перед синхронизацией, если требуется.
— 5 режимов поиска для элементов таблицы предварительного просмотра (по имени, по пути, по имени и пути, . ).
— 11 режимов фильтрации элементов таблицы предварительного просмотра (отсутствующие & разные, отсутствующие, разные, равные, . ).
— Синхронизация по сети. Возможность автоматического подключения сетевых папок до синхронизации.
— Защита от несанкционированных отключений дисков (папок) во время синхронизации.
— Сохранение последней / всех версий файлов для удаления. В этом режиме вы застрахованы от случайного удаления файлов, и всегда можете восстановить удаленные файлы, даже если папки синхронизированы несколько раз.
— Сравнение файлов с помощью «QuickLook» или «построчное» сравнение перед синхронизацией.
— Отображение выбранных файлов в Finder.
— Возможность открыть выбранные файлы в приложении по умолчанию.
— Выполнение операций с файлами для выбранных элементов таблицы предварительного просмотра.
— Возможность копировать выбранные элементы таблицы предварительного просмотра (отсутствующие, разные, . ) в третью папку (папка C).
— Урегулирование конфликта версий файлов.
— Для каждой пары папок отображается дата и время последней синхронизации.
— Процесс синхронизации регистрируется в журнал.
— Сохранение / загрузка настроек программы во внешний файл.
— Вы можете превратить приложение в удобный файловый менеджер с помощью мощных фильтров для файлов и папок и написания собственного сценария копирования.
— Синхронизация атрибутов подпапок.
— Написание собственных сценариев копирования файлов с помощью Unix команд.

Основное отличие от аналогичных приложений на App Store:
— Реальная двунаправленная синхронизация. Отслеживание удалений, добавлений, изменений в синхронизируемых папках.
— Более быстрая синхронизация больших папок.

Источник

Оцените статью