Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Delete Duplicates

Featured Replies

Here is the senior... I run a photography studio. I mostly photograph high school seniors. I have a database with about 7050 seniors in it, 5058 of which are unique. Each record has a date and time that the senior is to be photographed. The duplicates are about 2000 students that are entered from a previous shoot. I need a script that will delete the duplicate record(s) with the older dates ...

Example ???::

John Doe 7/2/03

John Doe 5/23/03

John Doe 3/18/03

I want only the john doe with the 7/2/03 date to remain in my file...

I am an amature when it comes to this stuff ... please help me!

...::: Also just another note to add - I don't know how many others on this site (if any) are in the same line of work as me. But if you are, please contact me and i will give you a copy of my program :::...

This is a simplified script, which uses a global text field, gCompare:

Show All Records

Sort (by name)

..Set field (gCompare, "")

Loop

..If(gCompare = name)

....Delete record

..Else

....Set field (gCompare, name)

....Go to record(next, exit after last)

..End If

Exit Loop If (Status (CurrentFoundCount) = 0 )

End Loop

  • Author

I am a little lost here .... whne you say ..If(gCompare = name).... what is the "name" supposed to be? also ... how does it keep only the most recent date ... like if i have the same record in my dbase twice ... One has a date for 5/9/03 and the other for 7/2/03 ... i want it to KEEP the 7/2/03

  • Author

ok I got it fugured out ... however ... there does seem to be one small problem ... if the final record in the database is a duplicate ... it deleted all copies of it .... ????:?:?:?:

AndyGaunt's method here.

1.Create a Selfjoin on the Name Field.

2.Sort the relationship by dates descending

3. Calculation

Case(Record_ID =???:Selfjoin:Record_ID),1,0).

Make a find for the "0", so you can purge the duplicates to keep the good ones.

In addition. I assumed the dates weren't entered in the order the records were created. If this is not the case, then you won't even need to sort the relationship, but you'd use

Case(Record_Id = Max(Selfjoin::Record_Id),1,0) with same effect.

1. If you want to use my script, add another line:

...

Exit Loop If (Status (CurrentFoundCount) = Status (CurrentRecord) )

Exit Loop If (Status (CurrentFoundCount) = 0 )

End Loop

2. You may have already figured out, sort by name and date descending

3. You may have figured out, I used "name" above as a placeholder for whatever criteria you're actually using, which could be a calc such as (NameFirst & NameLast & Phone) for example.

4. I sure hope you figured out: backup your file before you go testing this stuff!!!

  • 5 weeks later...
  • Author

Fitch said:

This is a simplified script, which uses a global text field, gCompare:

Show All Records

Sort (by name)

..Set field (gCompare, "")

Loop

..If(gCompare = name)

....Delete record

..Else

....Set field (gCompare, name)

....Go to record(next, exit after last)

..End If

Exit Loop If (Status (CurrentFoundCount) = 0 )

End Loop

Is there a faster alternative than this??? i am aging while waiting for this thing to go through 9000 records every day!!!

Every day? Hmmm... you might want to consider just keeping one record for each student, and keep their "shoot" records in a related file.

For now, to answer your question: before you run the script, or as the first step in the script, FIND the duplicate records. That way the script only has to check the found set instead of the whole file.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.