Benches macOS

2

Script to Compare File Contents in Two Fo…

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

I've looked through the Forum but can't find anything that seems quite to address my problem--and I'm really new to AppleScript, so please forgive me if this is a dumb question.

I burn a great many files of varying kinds (InDesign, Illustrator, Photoshop, PDF, etc.) to DVD everyday as part of my job. It happens not infrequently, though, that files drop out in the process and don't make it to the disk, with the result that I get calls from Manufacturing saying that I've screwed up and that random files X, Y, and Z are not on the disk that I sent.

I've tried various ways to failproof my burning routine, but utlimately, it seems like something still slips through sometimes--that is, the files are definitely in by Source Folder, but sometimes they don't leap the chasm to the disk. And since there can be several hundred files, it can be difficult to know at a glance if something is wrong.

It would be extremely helpful if there were a script that I could run to compare the contents of the folder source on my desktop (just say its called "Source Folder") with the contents of a disk I have just burned (whose name might vary, but whose folder structure is a duplicate of the subfolders in "Source Folder" that I have burned to disk. All I need the script to tell me is if there are files in my desktop Source Folder than are not on the burned disk).

Is this possible? I'd appreciate any help anyone could offer--right now, I'm printing up the disk directory and a list of the files from my desktop Source Folder and comparing them line for line, and my soul is dying.

Please help!

2 replies

Sign in or join Beachball Help to reply.

  1. 0

    Camelot

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    This can be pretty easily hacked together using a combination of AppleScript and shell scripting.

    There's a shell command
    diff that can tell if two directories are the same or not. You can use AppleScript to put a nice front-end on it, like:

    set src to (choose folder with prompt "Select the source directory")

    set dst to (choose folder with prompt "Select the destination directory/disk")

    try

    do shell script "diff -rq " & quoted form of POSIX path of src & space & quoted form of POSIX path of dst

    on error theErr

    display dialog "The following differences were found:" & return & return & theErr

    return

    end try

    display dialog "Directories match. No differences found"

    It's quick and dirty, but should get you started. It runs the
    diff command which triggers the 'on error' code if there are any differences. The script then reports the differences and exits. If there are no differences the 'on error' code is skipped and you get the all clear message.

  2. 0

    Wuddus

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Wow! This is extremely cool! Thank you so much! You've just made the lives of a number of us file-management drones here much, much better!