Lutando com sub-rotinas -- finder campo com applescript campo com file campo com mp3 camp apple Relacionado O problema

Struggling with Subroutines


0
vote

problema

português

Estou tendo, acho, um problema de sub-rotina. Eu quero usar esse sistema de 'escolha da lista' para encomendar música recém-adquirida. Depois de cair em um monte de MP3s, deve jogar o MP3 (para que eu possa decidir sobre o gênero), em seguida, exibir o primeiro diálogo 'Escolher de ...', que deve então levar para o próximo, até que atinja o um que solicita o Finder para arquivar o MP3. Então deve se mover para o próximo MP3. Mas por algum motivo, apenas joga o MP3.

Alguém pode ajudar? Desculpas pela massa do código, mas achei que poderia ser útil. Talvez eu tenha superado isso ... Mas eu acho que estou perguntando é possível ir de uma sub-rotina 'Escolher lista' para outra antes de voltar para o próximo arquivo na lista?

obrigado

atraso

  property extension_list : {"mp3", "m4a", "mp4", "aac"}   tell application "Finder"       --set folders as variables now...there are 15 folders       set f1 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/01 50s & 60s Rock"       set f2 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/02 70s & 80s Rock"       set f3 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/03 90s-now Rock"       set f4 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/04 Swing"       set f5 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/05 Soul"       set f6 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/06 Pop. Song"       set f7 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/07 Modern Jazz"       set f8 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/08 Comedy & Novelty & Christmas"       set f9 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/09 Spoken"       set f10 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/10 Blues, Gospel, Folk & World"       set f11 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/11 Classical"       set f12 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/12 Lounge & Exotica"       set f13 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/13 Rap"       set f14 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/14 Reggae"       set f15 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/15 Warped & Electronic"   end tell   --opens the dropped files   on open these_items --these_items are the dropped ones       repeat with i from 1 to the count of these_items           set this_item to item i of these_items           process_item(this_item)       end repeat   end open   -- this sub-routine processes files; this is the initial menu   on process_item(this_item)       -- NOTE that the variable this_item is a file reference in alias format        tell application "iTunes"           play this_item       end tell       tell application "Finder"           choose from list {"Rock", "Soul/Rap/Reggae", "Jazz/Pop. Song", "Other"} with title "Which genre?" with prompt "Identify genre from list:" cancel button name "Cancel"           if the result is {"Rock"} then               rockSubmenu(this_item)           else if the result is {"Soul/Rap/Reggae"} then               soulSubmenu(this_item)           else if the result is {"Jazz/Pop. Song"} then               jazzSubmenu(this_item)           else if the result is {"Other"} then               otherSubmenu(this_item)           end if       end tell   end process_item   --here are all the other submenus   on rockSubmenu(this_item)       choose from list {"50s & 60s", "70s & 80s", "90s-Now"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"50s & 60s"} then move this_item to f1       if the result is {"70s & 80s"} then move this_item to f2       if the result is {"90s-Now"} then move this_item to f3   end rockSubmenu   on soulSubmenu(this_item)       choose from list {"Soul", "Rap", "Reggae"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"Soul"} then           move this_item to f5       else if the result is {"Rap"} then           move this_item to f13       else if the result is {"Reggae"} then           move this_item to f14       end if   end soulSubmenu   on jazzSubmenu(this_item)       choose from list {"Swing", "Modern", "Pop. Song", "Lounge/Exotica"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"Swing"} then move this_item to f4       if the result is {"Modern"} then move this_item to f7       if the result is {"Pop. Song"} then move this_item to f6       if the result is {"Lounge/Exotica"} then move this_item to f12   end jazzSubmenu   on otherSubmenu(this_item)       choose from list {"Spoken", "Comedy/Novelty/Christmas", "Other"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"Spoken"} then move this_item to f9       if the result is {"Comedy/Novelty/Christmas"} then move this_item to f8       if the result is {"Other"} then other2Submenu(this_item)   end otherSubmenu   --another other menu   on other2Submenu(this_item)       choose from list {"Folk & World", "Classical", "Blues/Gospel", "Warped/Electronic"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"Classical"} then move this_item to f11       if the result is {"Blues/Gospel/Folk"} then move this_item to f10       if the result is {"Warped/Electronic"} then move this_item to f15       --end of all submenus   end other2Submenu      
english

I'm having, I think, a subroutine problem. I want to use this 'Choose from list' system to order newly acquired music. After dropping on a bunch of mp3s, it should play the mp3 (so I can decide on the genre), then display the first 'choose from...' dialog, which should then lead on to the next one, until it reaches the one which prompts Finder to file the mp3. Then it should move onto the next mp3. But for some reason it merely plays the mp3.

Can anyone help? Apologies for the mass of code but I thought it might be helpful. Maybe I've overcomplicated this... But I guess I'm asking is it possible to go from one 'choose list' subroutine to another before hopping back to the next file in the list?

Thanks

Tardy

property extension_list : {"mp3", "m4a", "mp4", "aac"}   tell application "Finder"       --set folders as variables now...there are 15 folders       set f1 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/01 50s & 60s Rock"       set f2 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/02 70s & 80s Rock"       set f3 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/03 90s-now Rock"       set f4 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/04 Swing"       set f5 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/05 Soul"       set f6 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/06 Pop. Song"       set f7 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/07 Modern Jazz"       set f8 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/08 Comedy & Novelty & Christmas"       set f9 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/09 Spoken"       set f10 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/10 Blues, Gospel, Folk & World"       set f11 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/11 Classical"       set f12 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/12 Lounge & Exotica"       set f13 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/13 Rap"       set f14 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/14 Reggae"       set f15 to POSIX file "/Users/Tardy/Tardy Stuff/Scripts & Automator Actions/Music Pre-Filing System/15 Warped & Electronic"   end tell   --opens the dropped files   on open these_items --these_items are the dropped ones       repeat with i from 1 to the count of these_items           set this_item to item i of these_items           process_item(this_item)       end repeat   end open   -- this sub-routine processes files; this is the initial menu   on process_item(this_item)       -- NOTE that the variable this_item is a file reference in alias format        tell application "iTunes"           play this_item       end tell       tell application "Finder"           choose from list {"Rock", "Soul/Rap/Reggae", "Jazz/Pop. Song", "Other"} with title "Which genre?" with prompt "Identify genre from list:" cancel button name "Cancel"           if the result is {"Rock"} then               rockSubmenu(this_item)           else if the result is {"Soul/Rap/Reggae"} then               soulSubmenu(this_item)           else if the result is {"Jazz/Pop. Song"} then               jazzSubmenu(this_item)           else if the result is {"Other"} then               otherSubmenu(this_item)           end if       end tell   end process_item   --here are all the other submenus   on rockSubmenu(this_item)       choose from list {"50s & 60s", "70s & 80s", "90s-Now"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"50s & 60s"} then move this_item to f1       if the result is {"70s & 80s"} then move this_item to f2       if the result is {"90s-Now"} then move this_item to f3   end rockSubmenu   on soulSubmenu(this_item)       choose from list {"Soul", "Rap", "Reggae"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"Soul"} then           move this_item to f5       else if the result is {"Rap"} then           move this_item to f13       else if the result is {"Reggae"} then           move this_item to f14       end if   end soulSubmenu   on jazzSubmenu(this_item)       choose from list {"Swing", "Modern", "Pop. Song", "Lounge/Exotica"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"Swing"} then move this_item to f4       if the result is {"Modern"} then move this_item to f7       if the result is {"Pop. Song"} then move this_item to f6       if the result is {"Lounge/Exotica"} then move this_item to f12   end jazzSubmenu   on otherSubmenu(this_item)       choose from list {"Spoken", "Comedy/Novelty/Christmas", "Other"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"Spoken"} then move this_item to f9       if the result is {"Comedy/Novelty/Christmas"} then move this_item to f8       if the result is {"Other"} then other2Submenu(this_item)   end otherSubmenu   --another other menu   on other2Submenu(this_item)       choose from list {"Folk & World", "Classical", "Blues/Gospel", "Warped/Electronic"} with title "Which genre?" with prompt "Choose from the following categories:" cancel button name "Cancel"       if the result is {"Classical"} then move this_item to f11       if the result is {"Blues/Gospel/Folk"} then move this_item to f10       if the result is {"Warped/Electronic"} then move this_item to f15       --end of all submenus   end other2Submenu   
           
   
   

Lista de respostas

0
 
vote
vote
Melhor resposta
 

Depois de mexer com isso por um tempo, consegui encontrar uma solução mais simples. Vou deixar isso aqui para qualquer pessoa também tentando classificar seus arquivos usando um sistema similar. Quando estiver em funcionamento, é muito mais rápido do que clicar em manualmente e procurar por pastas para classificar as coisas.

     --opens the dropped files on open these_items  --these_items are the dropped ones     repeat with i from 1 to the count of these_items         set this_item to item i of these_items         process_item(this_item)     end repeat end open  on process_item(this_item)     -- NOTE that the variable this_item is a file reference in alias format      --plays song so you can make a judgement     tell application "iTunes"         play this_item     end tell     --displays info of item to help decide genre     tell application "Finder"         set selectedItem to this_item         set infoList to {}         copy ("Displayed Name: " & displayed name of selectedItem) to end of infoList     end tell     set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}     set infoAsString to infoList as string     set AppleScript's text item delimiters to od     set the clipboard to infoAsString     tell me to activate     display dialog infoAsString giving up after 3.5     --moves item     tell application "Finder"         set defaultFolder to alias "Macintosh HD:Users:Tardy:Tardy Stuff:Scripts & Automator Actions:Music Pre-Filing System"     end tell     tell application "Finder"         choose folder default location (defaultFolder) with prompt "What genre?"         set theDestination to result         move this_item to theDestination     end tell   --stops music when sorting is complete     tell application "iTunes"         stop     end tell end process_item    

Obrigado por qualquer pessoa que trabalhava em uma resposta.

atraso

 

After messing about with this for a while, I managed to come up with a simpler solution. I'll leave it here for anyone also trying to sort their files using a similar system. When it's up and running, it's a lot faster than manually clicking and looking for folders to sort things into.

   --opens the dropped files on open these_items  --these_items are the dropped ones     repeat with i from 1 to the count of these_items         set this_item to item i of these_items         process_item(this_item)     end repeat end open  on process_item(this_item)     -- NOTE that the variable this_item is a file reference in alias format      --plays song so you can make a judgement     tell application "iTunes"         play this_item     end tell     --displays info of item to help decide genre     tell application "Finder"         set selectedItem to this_item         set infoList to {}         copy ("Displayed Name: " & displayed name of selectedItem) to end of infoList     end tell     set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}     set infoAsString to infoList as string     set AppleScript's text item delimiters to od     set the clipboard to infoAsString     tell me to activate     display dialog infoAsString giving up after 3.5     --moves item     tell application "Finder"         set defaultFolder to alias "Macintosh HD:Users:Tardy:Tardy Stuff:Scripts & Automator Actions:Music Pre-Filing System"     end tell     tell application "Finder"         choose folder default location (defaultFolder) with prompt "What genre?"         set theDestination to result         move this_item to theDestination     end tell   --stops music when sorting is complete     tell application "iTunes"         stop     end tell end process_item 

Thanks for anyone who was working on a reply.

Tardy

 
 

Perguntas relacionadas

2  Por que meus arquivos não importam para a GarageBand?  ( Why wont my files import into garageband ) 
Estou tentando importar um mp3 no GarageBand para alguma edição básica. Eu usei o navegador de mídia para localizar o arquivo e, em seguida, arrastar e solt...

10  Como substituir um MP3 ou M4A no iTunes por um arquivo de qualidade superior, sem ter que re-fazer listas de reprodução contendo a faixa?  ( How to replace an mp3 or m4a in itunes with a higher quality file without havin ) 
Eu tenho na minha biblioteca do iTunes Algumas músicas que, anos atrás, rasgei de CDs a taxas de apenas 128kbps. O armazenamento é barato agora e eu gostaria ...

14  Como posso baixar músicas gratuitas da internet para o iTunes no iPhone / iPad sem usar um Mac / PC?  ( How can i download free music from the internet to itunes on the iphone ipad wit ) 
Há cargas de bandas na Internet, oferecendo sua música como downloads gratuitos em seus sites. Como zips ou downloads de MP3 diretos. De que maneiras existem ...

3  Tornar o iTunes reconhecer audiobooks mp3 com tag id3  ( Make itunes recognize mp3 audiobooks with id3 tag ) 
Apple iTunes reconhece e categoriza arquivos de áudio mp4 (de preferência com um .m4b extensão, não abcdefghijklmn1 nem .mp4 ) corretamente como audioboo...

5  Adicionando MP3s ao iTunes 10 não funciona para alguns arquivos  ( Adding mp3s to itunes 10 doesnt work for some files ) 
Recentemente atualizado para o iTunes 10. Eu tinha alguns arquivos MP3 que gostaria de adicionar à biblioteca. No passado, arrastei a pasta para a seção do iT...

4  Mp3s conjunto como "audiobook" parou de aparecer no iBooks  ( Mp3s set as audiobook have stopped showing up in ibooks ) 
Por um tempo agora eu tenho importado MP3s, colocando-os como "audiobook" e ouvi-los via iBooks, como o normal. No entanto, por algum motivo desconhecido há a...

1  Como posso converter minha música GarageBand até um mp3 sem o ruído estático aumentando?  ( How can i convert my garageband tune to an mp3 without the static noise increasi ) 
Depois de exportar minha música GarageBand e convertê-lo para um MP3 e jogar no iTunes, o ruído estático de fundo é muito mais alto que no GarageBand. OS X ...

7  Atualizar o iTunes Match Metadata / Tags?  ( Updating itunes match metadata tags ) 
Eu recentemente liguei no iTunes, e fez sua coisa e correspondência / carregadas músicas. Eu então liguei no meu iPhone e ao meu horror, as tags que eu pensei...

1  Convertendo arquivo M4A para MP3 - arquivos selecionados não puderam ser encontrados  ( Converting m4a file to mp3 selected files could not be found ) 
iTunes iOS 12.9 no PC Eu quero converter arquivos M4A (neste caso, audiobooks) para mp3. Isso é o que aconteceu. . alterou as configurações de importaçã...

3  Existe alguma maneira de converter um monte de arquivos .ogg em uma pasta para .mp3 usando ffmpeg?  ( Is there any way to convert a bunch of ogg files in a folder to mp3 using ffmp ) 
Existe alguma maneira de converter uma pilha inteira de arquivos .ogg em cerca de 30 pastas em uma pasta contendo esses arquivos .mp3 e colocá-los em outra pa...




© 2022 pergunte.org All Rights Reserved. Casa de perguntas e respostas todos os direitos reservados


Licensed under cc by-sa 3.0 with attribution required.