Bonjour,

Voici un script qui supprime les x premiers caractères du titre de l'album ou de l'artiste dans une sélection iTunes.

J'aimerai partir de cette base pour supprimer le(s) x premier(s) mot(s).

Je commence juste depuis quelques jours la programmation AppleScript notamment grâce aux ouvrages que l'on ma conseillé sur ce forum.

Voici le script dans son état actuel

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
tell application "iTunes"
	set champs to {"Nom", "Artiste", "Album"}
	set morceaux to selection
	if morceaux is {} then
		display dialog "Vous devez sélectionner des morceaux !" buttons {"OK"} with icon caution giving up after 15
		return
	end if
 
	set champ to (choose from list champs with prompt "Quel champ éditer ?" default items "Nom") as string
	if champ is "false" then
		display dialog "Abandon du script !" buttons {"OK"} with icon note giving up after 15
		return
	end if
 
	repeat
		try
			set choix to display dialog "Combien caractères supprimer à la fin du champ \"" & champ & "\" ?" default answer "2" buttons {"OK"}
			set longueur to text returned of choix
			set longueur to (longueur as integer) + 1
			exit repeat
		on error
			display dialog "Vous devez entrer une valeur numérique !" with icon caution buttons {"OK"}
		end try
	end repeat
 
	-- supprimer en tête du champ
	repeat with morceau in morceaux
		tell morceau
			if champ is item 1 of champs then
				try
					set name to text longueur thru -1 of (get name)
				end try
			else if champ is item 2 of champs then
				try
					set artist to text longueur thru -1 of (get artist)
				end try
			else
				try
					set album to text longueur thru -1 of (get album)
				end try
			end if
		end tell
	end repeat
 
end tell
L'idée serait de remplacer la question combien de caractères par combien de
mots.

D'avance merci à tous pour votre aide
beus