| Vorheriges Thema anzeigen :: Nächstes Thema anzeigen   | 
	
	
	
		| Autor | 
		Nachricht | 
	
	
		Armin Egginger •-->
  
  
  Anmeldedatum: 04.05.2002 Beiträge: 96 Wohnort: Germering (b. München)
  | 
		
			
				 Verfasst am: 10.05.2003 - 17:34    Titel: OrdnerPfad aus dem Dateipfad extrahieren | 
				     | 
			 
			
				
  | 
			 
			
				Beschreibung:
 
 
Dieses Script extrahiert den OrdnerPfad aus dem DateiPfad, zur weiteren Verwendung.
 
 
Code:
 
set AppleScript's text item delimiters to ""
 
set ThePath to choose file
 
set theRest to RestofPath(ThePath)
 
theRest
 
 
on RestofPath(path)
 
   set pathstr to (path as string)
 
   set theReverse to (reverse of (characters of pathstr)) as string
 
   set theOset to offset of ":" in theReverse
 
   set theRest to (text 1 thru -theOset of pathstr)
 
   return theRest
 
end RestofPath
 
 
 
Andere Versionen willkommen!
 
happy filemaking
 
 
Armin | 
			 
		  | 
	
	
		| Nach oben | 
		 | 
	
	
		  | 
	
	
		ecco •->
  
 
  Anmeldedatum: 05.11.2001 Beiträge: 9
 
  | 
		
			
				 Verfasst am: 31.03.2004 - 23:34    Titel:  | 
				     | 
			 
			
				
  | 
			 
			
				da ich mit 'offset' kürzlich probleme hatte (eine ähnliche funktion lieferte immer den string in unicode zurück), hier eine weitere möglichkeit:
 
 
 	  | Code: | 	 		  
 
on extract_parent_folder_path_from(this_filepath)
 
   set this_filepath to this_filepath as text
 
   set parent_folder_path to ""
 
   set oldDelimiters to text item delimiters
 
   set text item delimiters to ":"
 
   repeat with i from 1 to (count of text items of this_filepath) - 1
 
      set parent_folder_path to parent_folder_path & text item i of this_filepath & ":"
 
   end repeat
 
   set text item delimiters to oldDelimiters
 
   return the parent_folder_path
 
end extract_parent_folder_path_from
 
 | 	  
 
 
ciao
 
ecco | 
			 
		  | 
	
	
		| Nach oben | 
		 | 
	
	
		  | 
	
	
		Markus_s •->
  
 
  Anmeldedatum: 15.08.2005 Beiträge: 5
 
  | 
		
			
				 Verfasst am: 15.08.2005 - 12:45    Titel:  | 
				     | 
			 
			
				
  | 
			 
			
				Als Einzeiler:
 
 
set theParent to alias ((text items 1 thru -2 of ((choose file) as text)) as text)
 
 
Gruß
 
Markus | 
			 
		  | 
	
	
		| Nach oben | 
		 | 
	
	
		  | 
	
	
		Markus_s •->
  
 
  Anmeldedatum: 15.08.2005 Beiträge: 5
 
  | 
		
			
				 Verfasst am: 15.08.2005 - 12:49    Titel:  | 
				     | 
			 
			
				
  | 
			 
			
				Nachtrag, doch nicht ganz korrekt:
 
 
set AppleScript's text item delimiters to ":"
 
set theParent to alias ((text items 1 thru -2 of ((choose file) as text)) as text)
 
 
Delimiter muß auf : stehen.
 
 
Gruß
 
Markus   | 
			 
		  | 
	
	
		| Nach oben | 
		 | 
	
	
		  | 
	
	
		spirigwi •----->
  
  
  Anmeldedatum: 10.07.2003 Beiträge: 1517 Wohnort: Olten-CH
  | 
		
			
				 Verfasst am: 15.08.2005 - 13:19    Titel:  | 
				     | 
			 
			
				
  | 
			 
			
				hallo Markus, gute IDEE!
 
 	  | Markus_s hat Folgendes geschrieben: | 	 		  Nachtrag, doch nicht ganz korrekt: 
 
 
set AppleScript's text item delimiters to ":" 
 
set theParent to alias ((text items 1 thru -2 of ((choose file) as text)) as text) 
 
 
Delimiter muß auf : stehen. 
 
 
  | 	  
 
hätte da noch eine Kleinigkeit
 
 
 	  | Zitat: | 	 		  set AppleScript's text item delimiters to ":"
 
set theParent to alias ((text items 1 thru -2 of ((choose file) as text)) as text)
 
set AppleScript's text item delimiters to ""
 
 
theParent  | 	  
 
 
  	  | Zitat: | 	 		  | Delimiter muß auf ""  stehen ! das wäre meine Maxime | 	   
 
PS:
 
was ist bei dir der out-put? _________________  Skript-Fan => ein  �  -Fan =>Scr¿¿-KongFuSius_Kurpfusius | 
			 
		  | 
	
	
		| Nach oben | 
		 | 
	
	
		  | 
	
	
		Markus_s •->
  
 
  Anmeldedatum: 15.08.2005 Beiträge: 5
 
  | 
		
			
				 Verfasst am: 15.08.2005 - 13:35    Titel:  | 
				     | 
			 
			
				
  | 
			 
			
				hallo spirigwi
 
 
Richtig, um den alten zustand wieder herzustellen (sofern der delimiter auf "" gestanden hat). Fürs Ergebniss hat es bei mir aber keine Bedeutung.
 
 
Gruß
 
Markus | 
			 
		  | 
	
	
		| Nach oben | 
		 | 
	
	
		  | 
	
	
		spirigwi •----->
  
  
  Anmeldedatum: 10.07.2003 Beiträge: 1517 Wohnort: Olten-CH
  | 
		
			
				 Verfasst am: 15.08.2005 - 13:39    Titel:  | 
				     | 
			 
			
				
  | 
			 
			
				Dies war die Frage:
 
 	  | MARKUS_s output hat Folgendes geschrieben: | 	 		  
 
alias "mcchef:Programme:Internet:Internet Programme:Internet Config 1.4:"
 
  | 	  
 
 
 	  | ARMINS output  hat Folgendes geschrieben: | 	 		  
 
"mcchef:Programme:Internet:Internet Programme:Internet Config 1.4:"
 
  | 	 
  _________________  Skript-Fan => ein  �  -Fan =>Scr¿¿-KongFuSius_Kurpfusius | 
			 
		  | 
	
	
		| Nach oben | 
		 | 
	
	
		  | 
	
	
		Snow Administrator
  
  
  Anmeldedatum: 21.11.2000 Beiträge: 1946 Wohnort: Deiningen
  | 
		
			
				 Verfasst am: 15.08.2005 - 15:16    Titel:  | 
				     | 
			 
			
				
  | 
			 
			
				Alle angegebenen Beispiele funktionieren aber nur, wenn man den Parent Folder einer Datei sucht.
 
 
Will man den Parenf Folder eines Ordners, klappt es so nicht mehr. Bitte ruhig mal mit 'choose folder' testen.
 
 
Ich nehme daher die universelle Methode - ist im Prinzip auch nicht anders, sondern eben nur ausgebaut:
 
 
set StoredPath to (choose folder) as string
 
 
set oldDelims to AppleScript's text item delimiters
 
set AppleScript's text item delimiters to ":"
 
set lastItem to the last text item of StoredPath
 
if lastItem = "" then
 
    set itemCount to -3 -- wenn ursprünglich Ordner 
 
else
 
    set itemCount to -2 -- wenn ursprünglich Datei
 
end if
 
set EventPath to ¬
 
    text 1 thru text item itemCount of StoredPath & ":"
 
set AppleScript's text item delimiters to oldDelims
 
 
EventPath
 
 
Siehe auch Workshop-Artikel "Parent Folder": _________________ Peter
 
-
 
Fischer-Bayern.de|Shadetreemicro.com | 
			 
		  | 
	
	
		| Nach oben | 
		 | 
	
	
		  | 
	
	
		 |