Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 8, 2010, 03:51 PM   #1
darkmaster87
macrumors newbie
 
Join Date: May 2010
How to make an applescript to delete iTunes duplicates?

I'm trying to make a program to find and delete duplicate files in iTunes but I don't know the code to delete files. Please help if you know a code that can delete half of the playlist showing the songs leaving only one copy of each song left.

Last edited by darkmaster87; May 8, 2010 at 04:45 PM.
darkmaster87 is offline   0 Reply With Quote
Old May 8, 2010, 04:42 PM   #2
chown33
macrumors 601
 
Join Date: Aug 2009
Google keywords: applescript to show iTunes duplicates

Before starting to develop something, the first step is to see if it already exists. If it exists and does exactly what you want, then problem solved with no additional development needed. If it's only close to what you want, then you at least have a working example to look at.
chown33 is offline   0 Reply With Quote
Old May 8, 2010, 04:48 PM   #3
-aggie-
macrumors Demi-God
 
-aggie-'s Avatar
 
Join Date: Jun 2009
Location: Where bunnies are welcome.
This will find the dupes and mark them. Pretty simple to delete them if you wanted.

PHP Code:
tell application "iPhoto"
    
set curPhotos to selection
    
    set theCount to 0
    repeat with thisPhoto in curPhotos
        set theCount to theCount 
1
        get theCount
        
if theCount 1 then
            set lastPhoto to thisPhoto
        
else
            if (
width of thisPhoto width of lastPhoto) and (height of thisPhoto height of lastPhoto) and (date of thisPhoto date of lastPhotothen
                set thisSize to size of 
(info for (image path of thisPhoto as POSIX file))
                
set lastSize to size of (info for (image path of lastPhoto as POSIX file))
                
                if 
thisSize ≥ lastSize then
                    
set comment of thisPhoto to "duplicate"
                
else
                    
set comment of lastPhoto to "duplicate"
                
end if
                
            
end if
            
set lastPhoto to thisPhoto
            
        end 
if
        
    
end repeat
    
    beep
    beep
    display alert 
"All duplicate photos have been marked DUPLICATE"
end tell 
__________________
Google with site:macrumors.com as a parameter.
DFU Mode........People with Obama in White Face avatars – proving how stupid they are one post at a time
-aggie- is offline   0 Reply With Quote
Old May 8, 2010, 04:49 PM   #4
darkmaster87
Thread Starter
macrumors newbie
 
Join Date: May 2010
Quote:
Originally Posted by chown33 View Post
Google keywords: applescript to show iTunes duplicates

Before starting to develop something, the first step is to see if it already exists. If it exists and does exactly what you want, then problem solved with no additional development needed. If it's only close to what you want, then you at least have a working example to look at.
I have looked for an existing program that does this but none of them are free and the demos won't work on my computer for some reason.
darkmaster87 is offline   0 Reply With Quote
Old May 8, 2010, 04:50 PM   #5
miles01110
macrumors 604
 
miles01110's Avatar
 
Join Date: Jul 2006
Location: The Ivory Tower (I'm not coming down)
Quote:
Originally Posted by darkmaster87 View Post
I have looked for an existing program that does this but none of them are free and the demos won't work on my computer for some reason.
I assume you also know about the "Display Duplicates" feature built into iTunes? Is that not what you're looking for? See attached image.

Quote:
Originally Posted by -aggie- View Post
This will find the dupes and mark them. Pretty simple to delete them if you wanted.
Well... kind of. This is for photos. For iTunes duplicates dougscripts has a number of duplicate deletion scripts.
Attached Thumbnails
Click image for larger version

Name:	Picture 2.png
Views:	14
Size:	76.0 KB
ID:	225503  
__________________
Got a problem? Check here first.
miles01110 is offline   0 Reply With Quote
Old May 8, 2010, 04:58 PM   #6
-aggie-
macrumors Demi-God
 
-aggie-'s Avatar
 
Join Date: Jun 2009
Location: Where bunnies are welcome.
Quote:
Originally Posted by miles01110 View Post
I assume you also know about the "Display Duplicates" feature built into iTunes? Is that not what you're looking for? See attached image.



Well... kind of. This is for photos. For iTunes duplicates dougscripts has a number of duplicate deletion scripts.
Ugh! Was going through my Applescripts and forgot this was for iTunes. Yes, dougscripts has that. However, he may not be able to see the source code.

Edit: Looks like he'll only find Dupin, which is now a paid Applescript.
__________________
Google with site:macrumors.com as a parameter.
DFU Mode........People with Obama in White Face avatars – proving how stupid they are one post at a time
-aggie- is offline   0 Reply With Quote
Old May 8, 2010, 05:03 PM   #7
darkmaster87
Thread Starter
macrumors newbie
 
Join Date: May 2010
Quote:
Originally Posted by miles01110 View Post
I assume you also know about the "Display Duplicates" feature built into iTunes? Is that not what you're looking for? See attached image.
Yes, I know that iTunes has the "Display Duplicates" feature built in. My code uses that to only show duplicates so that the following code only affects duplicated files and not my entire library. The problem is deleting the files after I have excluded the non-duplicates, which I don't know the code to do.
darkmaster87 is offline   0 Reply With Quote
Old May 8, 2010, 05:24 PM   #8
-aggie-
macrumors Demi-God
 
-aggie-'s Avatar
 
Join Date: Jun 2009
Location: Where bunnies are welcome.
Quote:
Originally Posted by darkmaster87 View Post
Yes, I know that iTunes has the "Display Duplicates" feature built in. My code uses that to only show duplicates so that the following code only affects duplicated files and not my entire library. The problem is deleting the files after I have excluded the non-duplicates, which I don't know the code to do.
Something like this:

PHP Code:
repeat with theFile in the result
    set itemPath to the 
(theFile as text)
    do 
shell script "rm -r " & (quoted form of POSIX path of itemPath)
end repeat 
__________________
Google with site:macrumors.com as a parameter.
DFU Mode........People with Obama in White Face avatars – proving how stupid they are one post at a time
-aggie- is offline   0 Reply With Quote
Old May 8, 2010, 05:31 PM   #9
darkmaster87
Thread Starter
macrumors newbie
 
Join Date: May 2010
Quote:
Originally Posted by -aggie- View Post
Something like this:

PHP Code:
repeat with theFile in the result
    set itemPath to the 
(theFile as text)
    do 
shell script "rm -r " & (quoted form of POSIX path of itemPath)
end repeat 
I added it to my code but it didn't do anything. Does it require a separate file to work or something?
darkmaster87 is offline   0 Reply With Quote
Old May 8, 2010, 05:34 PM   #10
-aggie-
macrumors Demi-God
 
-aggie-'s Avatar
 
Join Date: Jun 2009
Location: Where bunnies are welcome.
Quote:
Originally Posted by darkmaster87 View Post
I added it to my code but it didn't do anything. Does it require a separate file to work or something?
Well, of course you have to supply the repeat with thefile from the result. I figured you'd got that far, so you had some "results" which you could then go through to get "thefile" to be deleted. Do you know how to read Applescript??
__________________
Google with site:macrumors.com as a parameter.
DFU Mode........People with Obama in White Face avatars – proving how stupid they are one post at a time
-aggie- is offline   0 Reply With Quote
Old May 8, 2010, 05:47 PM   #11
darkmaster87
Thread Starter
macrumors newbie
 
Join Date: May 2010
Quote:
Originally Posted by -aggie- View Post
Well, of course you have to supply the repeat with thefile from the result. I figured you'd got that far, so you had some "results" which you could then go through to get "thefile" to be deleted. Do you know how to read Applescript??
I can't read it that well, most of the time I have to go to the dictionary and files that are similar to what I am making to find codes
darkmaster87 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
how to make an iso into a img (does not work as an .iso) mud25 Mac Basics and Help 2 Jul 19, 2011 09:30 PM
Way to delete podcast downloads from the Downloads window? BlueberryMac Mac Applications and Mac App Store 1 Mar 28, 2011 05:24 AM
iTunes, duplicating? Eldiablojoe iPod 2 Feb 21, 2011 12:13 PM
How to set an applescript to run when I open iTunes. . . PiecesOF8 Mac Programming 3 May 28, 2009 07:39 PM
How to make an Alias to a QT stream? todd2000 Mac Applications and Mac App Store 0 Feb 22, 2008 11:49 PM


All times are GMT -5. The time now is 01:14 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC