Wav -> Public Dropbox-Mp3-Link

T

tim_buktu

Mitglied
Thread Starter
Dabei seit
18.01.2008
Beiträge
38
Reaktionspunkte
0
Hi zusammen,

ich suche nach einem Weg, meinen Workflow zu vereinfachen.

Bisher exportiere ich meine Dateien aus Ableton Live als Wav, konvertiere sie mit iTunes zu Mp3, ziehe sie in meinen Dropbox-Ordner und kopiere den Public-Link, um ihn per Mail zu versenden. Ich bin schon so weit, dass ein modifiziertes Droplet von Doug's Apple Script das Konvertieren übernimmt und die Datei in meine Public Folder bewegt.

Was ich aber will:
-Auf Knopfdruck nimmt das Script sich die zuletzt modifizierte Datei aus einem vorher festgelegten Ordner.
-Es konvertiert sie zu MP3
-Zielordner ist meine Dropbox-Publicfolder
-Es kopiert den Public Link für mich
-(Es macht eine Mail mit vorher definiertem Empfänger auf und kopiert den Link in den Text)

Vielleicht hat ja ein Applescript-bewanderter Musiker hier das gleiche Problem bei der Zusammenarbeit über das Internet und möchte helfen. So weit bin ich bisher:

Code:
(*
"Drop A Few My Way" for iTunes
written by Doug Adams
dougadams@mac.com

v2.0 oct 1 2009
- universal binary
- serious maintenance updates (last update was 2004!)

v1.0 mar 9 04
initial release

Get more free AppleScripts and info on writing your own
at Doug's AppleScripts for iTunes
http://dougscripts.com/itunes/

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Get a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

or visit http://www.gnu.org/copyleft/gpl.html

*)



property my_title : "Drap A Few My Way"
property enc_list : {"mp3"}
property encoder_possibilities : {".mp3"}
property errTxt : ("(One or more files may not have been converted correctly.)" & return & return)

global newTrack -- reference to converted track
global newFile -- reference to converted file
global backedupEncoder -- stash encoder from Preferences
global targetLocation -- path to folder where converted files will be saved
global new_filename_and_extension -- name created from type of 
global encoder_options -- list of encoders
global new_extension -- extension of new file, based on encoder selection
global encoderShortName -- first item of selected encoder to get string to use in dialogs
global err_mess -- mention an error

on run
	display dialog "This is a droplet. Drop audio files on this script's icon to convert them." buttons {"OK"} default button 1
	return
	
	(* -- debugging
	set err_mess to ""
	set fs to (choose file) as list
	my proceed_(fs)
	*)
end run

on open fs
	set err_mess to ""
	my proceed_(fs)
end open

on proceed_(fs)
	-- plural for dialogs
	set s to "s"
	if (length of fs) is 1 then set s to ""
	
	my init_encoders_()
	set selectedEncoder to ((backedupEncoder))
	repeat with i from 1 to length of enc_list
		if selectedEncoder starts with (item i of enc_list) then
			set new_extension to item i of encoder_possibilities
			set encoderShortName to first word of selectedEncoder
		end if
	end repeat
	
	set targetLocation to ("/users/tim/Dropbox/Public/") as text
	tell application "iTunes" to set current encoder to encoder selectedEncoder
	
	repeat with f in fs
		try -- skip bad files
			with timeout of 30000 seconds -- plenty of time
				my itunes_convert_(f)
			end timeout
		on error m number n
			-- log (m & return & n) -- debugging
		end try
	end repeat
	tell application "iTunes" to set current encoder to encoder backedupEncoder
	
	-- comment the next 2 lines to keep from being notified
	tell me to activate
	tell me to display dialog (err_mess & "Done converting audio file" & s & " to " & encoderShortName & ".") buttons {"Thanks"} default button 1 with title my_title giving up after 5
	
end proceed_

to itunes_convert_(f)
	set finfo to get info for f
	set new_filename_and_extension to ((text 1 thru -((length of name extension of finfo) + 2) of (name of finfo)) & new_extension)
	
	tell application "iTunes"
		try
			set newTrack to first item of (convert f)
			set newFile to (get location of newTrack) as text
			delete newTrack
		on error m number n
			-- log (m & return & n) -- debugging
			set err_mess to errTxt
		end try
	end tell
	
	-- move to the new location, rename to ensure appended numbers -- if any -- do not stay with the file name
	do shell script "mv " & (quoted form of POSIX path of newFile) & " " & (quoted form of POSIX path of (targetLocation & new_filename_and_extension) as text)
	
	-- remove from location in iTunes Media folder if it's there (most likely)
	if (f as text) is not (newFile as text) then do shell script "rm " & (quoted form of POSIX path of newFile)
	
end itunes_convert_

to init_encoders_()
	tell application "iTunes"
		launch
		set encoder_options to (get name of every encoder)
		set backedupEncoder to name of current encoder
	end tell
end init_encoders_
 
Update!

Hallo nochmal,

mittlerweile kann das Script fast alles, außer das automatische Finden der Datei. D.h. im Moment zieht man eine WAV/Aiff auf das Droplet, es konvertiert sie zu Mp3, läd sie zu Dropbox hoch, tut den Public Link in die Zwischenablage und macht eine Mail an eine vordefinierte Adresse auf mit der URL drin.

Kriegt irgendeiner es noch hin, die zuletzt modifizierte Datei eines Ordners abzugreifen?
Code:
(*
"Drop A Few My Way" for iTunes
written by Doug Adams
dougadams@mac.com

v2.0 oct 1 2009
- universal binary
- serious maintenance updates (last update was 2004!)

v1.0 mar 9 04
initial release

Get more free AppleScripts and info on writing your own
at Doug's AppleScripts for iTunes
http://dougscripts.com/itunes/

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Get a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

or visit http://www.gnu.org/copyleft/gpl.html

*)



property my_title : "Drap A Few My Way"
property enc_list : {"mp3"}
property encoder_possibilities : {".mp3"}
property errTxt : ("(One or more files may not have been converted correctly.)" & return & return)

global newTrack -- reference to converted track
global newFile -- reference to converted file
global backedupEncoder -- stash encoder from Preferences
global targetLocation -- path to folder where converted files will be saved
global new_filename_and_extension -- name created from type of 
global encoder_options -- list of encoders
global new_extension -- extension of new file, based on encoder selection
global encoderShortName -- first item of selected encoder to get string to use in dialogs
global err_mess -- mention an error

on run
	display dialog "This is a droplet. Drop audio files on this script's icon to convert them." buttons {"OK"} default button 1
	return
	
	(* -- debugging
	set err_mess to ""
	set fs to (choose file) as list
	my proceed_(fs)
	*)
end run

on open fs
	set err_mess to ""
	my proceed_(fs)
end open

on proceed_(fs)
	-- plural for dialogs
	set s to "s"
	if (length of fs) is 1 then set s to ""
	
	my init_encoders_()
	set selectedEncoder to ((backedupEncoder))
	repeat with i from 1 to length of enc_list
		if selectedEncoder starts with (item i of enc_list) then
			set new_extension to item i of encoder_possibilities
			set encoderShortName to first word of selectedEncoder
		end if
	end repeat
	
	set targetLocation to ("/users/DEIN_USER/Dropbox/Public/") as text
	tell application "iTunes" to set current encoder to encoder selectedEncoder
	
	repeat with f in fs
		try -- skip bad files
			with timeout of 30000 seconds -- plenty of time
				my itunes_convert_(f)
			end timeout
		on error m number n
			-- log (m & return & n) -- debugging
		end try
	end repeat
	tell application "iTunes" to set current encoder to encoder backedupEncoder
	
	-- comment the next 2 lines to keep from being notified
	
end proceed_

to itunes_convert_(f)
	set finfo to get info for f
	set new_filename_and_extension to ((text 1 thru -((length of name extension of finfo) + 2) of (name of finfo)) & new_extension)
	
	tell application "iTunes"
		try
			set newTrack to first item of (convert f)
			set newFile to (get location of newTrack) as text
			delete newTrack
		on error m number n
			-- log (m & return & n) -- debugging
			set err_mess to errTxt
		end try
	end tell
	
	-- move to the new location, rename to ensure appended numbers -- if any -- do not stay with the file name
	do shell script "mv " & (quoted form of POSIX path of newFile) & " " & (quoted form of POSIX path of (targetLocation & new_filename_and_extension) as text)
	
	set theURL to "http://dl.getdropbox.com/u/DEINE_ID/" & new_filename_and_extension
	set the clipboard to theURL as text
	--display dialog theURL & " copied to clipboard."
	
	
	
	
	--Variables
	set recipientName to "Wuwu Wawa"
	set recipientAddress to "wuwu@wawa.com"
	set theSubject to new_filename_and_extension
	set theContent to theURL
	
	--Mail Tell Block
	tell application "Mail"
		
		--Create the message
		set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
		
		--Set a recipient
		tell theMessage
			make new to recipient with properties {name:recipientName, address:recipientAddress}
			
			
			
		end tell
	end tell
	-- remove from location in iTunes Media folder if it's there (most likely)
	if (f as text) is not (newFile as text) then do shell script "rm " & (quoted form of POSIX path of newFile)
	
	
	
end itunes_convert_
to switchText from t to r instead of s
	set d to text item delimiters
	set text item delimiters to s
	set t to t's text items
	set text item delimiters to r
	tell t to set t to item 1 & ({""} & rest)
	set text item delimiters to d
	t
end switchText



to init_encoders_()
	tell application "iTunes"
		launch
		set encoder_options to (get name of every encoder)
		set backedupEncoder to name of current encoder
	end tell
end init_encoders_
 
Hallo!

tell application "Finder"
set x to files in folder "X:Y:Z:"
set lmd to item 1 of (sort x by modification date) as alias
end tell


oder falls es noch Unterordner gibt
set x to files of entire contents of folder "X:Y:Z:"

Gruß
 
Hey, vielen Dank! Die neueste Datei findet er schonmal. Allerdings macht er dann auf dem Weg zum Converter Probleme:

Code:
Can’t get length of alias "Untitled 1:Users:MYUSERNAME:Desktop:Export:SONG.wav"

Ne Ahnung, wie man das fixen kann?
 
Sorry. Ich habe gerade nicht die Zeit (und die Muße), mir dein Skript anzuschauen :eek:
Mach mal aus dem as alias in meinem Beispielscript ein as string

Gruß
 
Mach mal aus dem as alias in meinem Beispielscript ein as string

Gruß
wenn ich das mache und das programm aufrufe, läufts kurz und geht wieder zu :/

hier nochmal der gesamte code inklusive deines beispiels:

Code:
(*
"Drop A Few My Way" for iTunes
written by Doug Adams
dougadams@mac.com

v2.0 oct 1 2009
- universal binary
- serious maintenance updates (last update was 2004!)

v1.0 mar 9 04
initial release

Get more free AppleScripts and info on writing your own
at Doug's AppleScripts for iTunes
http://dougscripts.com/itunes/

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Get a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

or visit http://www.gnu.org/copyleft/gpl.html

*)



property my_title : "Drap A Few My Way"
property enc_list : {"mp3"}
property encoder_possibilities : {".mp3"}
property errTxt : ("(One or more files may not have been converted correctly.)" & return & return)

global newTrack -- reference to converted track
global newFile -- reference to converted file
global backedupEncoder -- stash encoder from Preferences
global targetLocation -- path to folder where converted files will be saved
global new_filename_and_extension -- name created from type of 
global encoder_options -- list of encoders
global new_extension -- extension of new file, based on encoder selection
global encoderShortName -- first item of selected encoder to get string to use in dialogs
global err_mess -- mention an error

on run
	
	tell application "Finder"
		set x to files in folder "Untitled 1:Users:USERNAME:Desktop:Export:"
		set fs to item 1 of (sort x by modification date) as string
	end tell
	
	
	
	-- plural for dialogs
	set s to "s"
	if (length of fs) is 1 then set s to ""
	
	my init_encoders_()
	set selectedEncoder to ((backedupEncoder))
	repeat with i from 1 to length of enc_list
		if selectedEncoder starts with (item i of enc_list) then
			set new_extension to item i of encoder_possibilities
			set encoderShortName to first word of selectedEncoder
		end if
	end repeat
	
	set targetLocation to ("/users/USERNAME/Dropbox/Public/") as text
	tell application "iTunes" to set current encoder to encoder selectedEncoder
	
	repeat with f in fs
		try -- skip bad files
			with timeout of 30000 seconds -- plenty of time
				my itunes_convert_(f)
			end timeout
		on error m number n
			-- log (m & return & n) -- debugging
		end try
	end repeat
	tell application "iTunes" to set current encoder to encoder backedupEncoder
	
	-- comment the next 2 lines to keep from being notified
	
end run

to itunes_convert_(f)
	set finfo to get info for f
	set new_filename_and_extension to ((text 1 thru -((length of name extension of finfo) + 2) of (name of finfo)) & new_extension)
	
	tell application "iTunes"
		try
			set newTrack to first item of (convert f)
			set newFile to (get location of newTrack) as text
			delete newTrack
		on error m number n
			-- log (m & return & n) -- debugging
			set err_mess to errTxt
		end try
	end tell
	
	-- move to the new location, rename to ensure appended numbers -- if any -- do not stay with the file name
	do shell script "mv " & (quoted form of POSIX path of newFile) & " " & (quoted form of POSIX path of (targetLocation & new_filename_and_extension) as text)
	
	set theURL to "http://dl.getdropbox.com/u/DROPBOX_ID/" & new_filename_and_extension
	set the clipboard to theURL as text
	--display dialog theURL & " copied to clipboard."
	
	
	
	
	--Variables
	set recipientName to "WUWU"
	set recipientAddress to "WUWU@WAWA.com"
	set theSubject to new_filename_and_extension
	set theContent to theURL
	
	--Mail Tell Block
	tell application "Mail"
		
		--Create the message
		set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
		
		--Set a recipient
		tell theMessage
			make new to recipient with properties {name:recipientName, address:recipientAddress}
			
			
			
		end tell
	end tell
	-- remove from location in iTunes Media folder if it's there (most likely)
	if (f as text) is not (newFile as text) then do shell script "rm " & (quoted form of POSIX path of newFile)
	
	
	
end itunes_convert_
to switchText from t to r instead of s
	set d to text item delimiters
	set text item delimiters to s
	set t to t's text items
	set text item delimiters to r
	tell t to set t to item 1 & ({""} & rest)
	set text item delimiters to d
	t
end switchText



to init_encoders_()
	tell application "iTunes"
		launch
		set encoder_options to (get name of every encoder)
		set backedupEncoder to name of current encoder
	end tell
end init_encoders_

edit: verstehe, wenn du keine zeit und muße hast - fremde zusammenkopierte skripte sind bestimmt nicht schön zu lesen ;) aber vielleicht siehst du ja am anfang irgendwas, was helfen könnte.

edit 2: im originalskript stand am anfang das hier, um die auf das droplet gezogene datei abzugreifen. vielleicht hilft das:
 
Hallo!

*grins
Ich bin wirklich gerade etwas "busy"

verstehe, wenn du keine zeit und muße hast - fremde zusammenkopierte skripte sind bestimmt nicht schön zu lesen aber vielleicht siehst du ja am anfang irgendwas, was helfen könnte.
Da hast du allerdings recht.
Und ja, ich sehe spontan eine Zeile, die das ganze scheitern lässt.

Nur....
Deine Lösung über iTunes ist echt nicht schön.
Wenn hier eine praktische Lösung für den fehlenden mp3 Export in Ableton Live erarbeitet werden soll, dann meiner Meinung nach nur mit dem LAME encoder.
Hier der Link zu LAME. Auf der Seite findest du auch irgendwo Links mit schon kompilierten Versionen oder eventuell auch eine Anleitung, wie du das selber machst. (Ansonsten Google)
Ausserdem noch Anwendungsbeispiele.

Kurz: LAME ist ein Command Line Tool und kann mit AppleScript angesteuert werden

Hier ein BeispielSkript
Angenommen dein File hat die Endung .xxx (also z.B. .wav oder .aif)

Code:
tell application "Finder"
	set x to files in folder "Pfad:zu:deinem:Ordner"
	set f to item 1 of (sort x by modification date) as alias
end tell

set f to POSIX path of f
tell f
	set mp3f to text 1 thru -5
end tell

do shell script "/usr/local/bin/lame -h " & quoted form of f & " " & quoted form of mp3f & ".mp3"

Das File wird in mp3 umgewandelt und liegt im selben Ordner wie das Original
Die Kurzform des do shell script wäre
do shell script "/usr/local/bin/lame -h " & quoted form of f
...nur dann wird die Endung .mp3 einfach angehängt

Denk mal drüber nach, ob das was wäre
Gruß


Edit: Hier gibt es einen Installer für 10.6
 
Zuletzt bearbeitet:
Zurück
Oben Unten