Séparer chiffres et lettres par un espace

Mince j'avais oublié le caractère " c'est un peut particulier. je te mets le script modifié.

Bloc de code:
tell application "Finder"
    set laref to the clipboard
    set lesChar to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
    set leNbchar to count of every character of laref
    set place to 1
    set newref to laref
   
    repeat with i from 2 to leNbchar - 1
        set place to place + 1
        set lechar1 to character i of laref
        set lechar2 to character (i + 1) of laref
        set lechar0 to character (i - 1) of laref
        if lechar1 is in lesChar then
            if lechar0 is not in lesChar then
                if lechar0 = " " then
                else
                    set newref to characters 1 thru (place - 1) of newref & " " & characters place thru -1 of newref as string
                    set place to (place + 1)
                end if
            end if
            if lechar2 is not in lesChar then
                if lechar2 = " " then
                else
                    set newref to characters 1 thru (place) of newref & " " & characters (place + 1) thru -1 of newref as string
                    set place to (place + 1)
                end if
            end if
        end if
    end repeat
   
    set lesCharspe to {"<", ">", "@", "#", "&", ":", "/", "*", "-", "+", "_", ",", ".", ":", "+", "=", "%", "*", "'", "(", ")", "!", "?", "\""}
    repeat with i from 1 to count of every character of newref
        if character i of newref is in lesCharspe then
            set newref to characters 1 thru (i - 1) of newref & " " & characters (i + 1) thru -1 of newref as string
        end if
    end repeat
   
    set supespace to newref
    set place to 1
    repeat with i from 1 to (count of every character of newref) - 2
        set lechar1 to character place of supespace
        set lechar2 to character (place + 1) of supespace
       
        if lechar1 = " " then
            if lechar2 = " " then
                set supespace to characters 1 thru (place - 1) of supespace & characters (place + 1) thru -1 of supespace as string
                set place to place - 1
            end if
        end if
        set place to place + 1
    end repeat
   
    set the clipboard to supespace
end tell
 
Tiens mon nouveau post n'est pas visible ! :banghead:

Edit: Il est là :angelic::p
 
Erreur !:bigtears:
 
C'est parfait, c'est exactement ce que je voulais.

Sur une référence aa111-22-b3cd au lieu de 10 actions il n'en reste plus que 3. De plus, pas de risques d'erreur.

Merci encore pour le temps que tu as passé sur mon problème. C'est pas grave pour le "Coller", c'est moins problématique et tout aussi rapide.

Je ne t'embête plus :)
 
Pas de problème, tu ne m'embêtes pas !

Content pour toi.
bonne journée.
 
C'est encore moi :)
j'ai juste un petit problème quand ma ref se termine par un chiffre, il n'ajoute pas le dernier espace.

aaa55b5 -> aaa 55 b5
 
Ah ! je regarde !
 
Bon effectivement si la ref se terminait par un seul chiffre ça ne fonctionnait pas.
je te met le nouveau modifié
Désolé pour le bug (on pense pas à tout) :banghead: :D

Bloc de code:
tell application "Finder"
    set laref to the clipboard
    set lesChar to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
    set leNbchar to count of every character of laref
    set place to 1
    set newref to laref
   
    repeat with i from 2 to leNbchar
        set place to place + 1
        if i = leNbchar then
            set lechar2 to "a"
        else
            set lechar2 to character (i + 1) of laref
        end if
        set lechar1 to character i of laref
        set lechar0 to character (i - 1) of laref
        if lechar1 is in lesChar then
            if lechar0 is not in lesChar then
                if lechar0 = " " then
                else
                    set newref to characters 1 thru (place - 1) of newref & " " & characters place thru -1 of newref as string
                    set place to (place + 1)
                end if
            end if
            if i = leNbchar then
            else
                if lechar2 is not in lesChar then
                    if lechar2 = " " then
                    else
                        set newref to characters 1 thru (place) of newref & " " & characters (place + 1) thru -1 of newref as string
                        set place to (place + 1)
                    end if
                end if
            end if
        end if
    end repeat
   
    set lesCharspe to {"<", ">", "@", "#", "&", ":", "/", "*", "-", "+", "_", ",", ".", ":", "+", "=", "%", "*", "'", "(", ")", "!", "?", "\""}
    repeat with i from 1 to count of every character of newref
        if character i of newref is in lesCharspe then
            set newref to characters 1 thru (i - 1) of newref & " " & characters (i + 1) thru -1 of newref as string
        end if
    end repeat
   
    set supespace to newref
    set place to 1
    repeat with i from 1 to (count of every character of newref) - 2
        set lechar1 to character place of supespace
        set lechar2 to character (place + 1) of supespace
       
        if lechar1 = " " then
            if lechar2 = " " then
                set supespace to characters 1 thru (place - 1) of supespace & characters (place + 1) thru -1 of supespace as string
                set place to place - 1
            end if
        end if
        set place to place + 1
    end repeat
   
    set the clipboard to supespace
end tell
 
Bonjour Zeltron54, excuse moi encore de te déranger j'ai un tout petit bug avec ton script, en effet si la ref commence par un seul chiffre ça ne fonctionne pas. 1xxx555 -> 1xxx 555
sinon c'est du caviar tous les jours :)
 
Bonjour,
Alors voilà une nouvelle version...
J'espère que ça te conviendra, dis-moi ci c'est bon ....
Bloc de code:
tell application "Finder"
    set laref to the clipboard
    set lesChar to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
    set leNbchar to count of every character of laref
    set place to 1
    set newref to laref
   
    repeat with i from 2 to leNbchar
        set place to place + 1
        if i = leNbchar then
            set lechar2 to "a"
        else
            set lechar2 to character (i + 1) of laref
        end if
        set lechar1 to character i of laref
        set lechar0 to character (i - 1) of laref
       
        if i = 2 then
            if lechar0 is in lesChar then
                if lechar1 is not in lesChar then
                    set newref to characters 1 thru (place - 1) of newref & " " & characters place thru -1 of newref as string
                    set place to (place + 1)
                end if
            end if
        end if
       
        if lechar1 is in lesChar then
            if lechar0 is not in lesChar then
                if lechar0 = " " then
                else
                    set newref to characters 1 thru (place - 1) of newref & " " & characters place thru -1 of newref as string
                    set place to (place + 1)
                end if
               
            end if
            if i = leNbchar then
            else
                if lechar2 is not in lesChar then
                    if lechar2 = " " then
                    else
                        set newref to characters 1 thru (place) of newref & " " & characters (place + 1) thru -1 of newref as string
                        set place to (place + 1)
                    end if
                end if
            end if
        end if
    end repeat
   
    set lesCharspe to {"<", ">", "@", "#", "&", ":", "/", "*", "-", "+", "_", ",", ".", ":", "+", "=", "%", "*", "'", "(", ")", "!", "?", "\""}
    repeat with i from 1 to count of every character of newref
        if character i of newref is in lesCharspe then
            set newref to characters 1 thru (i - 1) of newref & " " & characters (i + 1) thru -1 of newref as string
        end if
    end repeat
   
    set supespace to newref
    set place to 1
    repeat with i from 1 to (count of every character of newref) - 2
        set lechar1 to character place of supespace
        set lechar2 to character (place + 1) of supespace
       
        if lechar1 = " " then
            if lechar2 = " " then
                set supespace to characters 1 thru (place - 1) of supespace & characters (place + 1) thru -1 of supespace as string
                set place to place - 1
            end if
        end if
        set place to place + 1
    end repeat
   
    set the clipboard to supespace
end tell
 
Content pour toi
Bonne soirée !