Fischer-Bayern.de
 FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   BenutzergruppenBenutzergruppen   RegistrierenRegistrieren 
 ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin 

help me Unterordner

 
Dieses Forum ist gesperrt, du kannst keine Beiträge editieren, schreiben oder beantworten.   Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.    Fischer-Bayern.de Foren-Übersicht -> AppleScript-Forum
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
peterpeter
•->
•->


Anmeldedatum: 29.05.2001
Beiträge: 1

BeitragVerfasst am: 29.05.2001 - 17:35    Titel: help me Unterordner Antworten mit Zitat

Hallo, bin ein richtiger Neuling in apple script und hab da ein Problem, ein Programm soll einen ordner und deren unterordner überwachen. das script anbei überwacht nur einen ordner nicht deren unterordner.
das programm ist cumulus und das script fügt neue files in die cumulus hinzu, wunderbar, aber halt ignoriert die unterordner.
hab auch mal versucht das script mit den rekursiven handler mit einzubinden, aber ohne erfolg. wer kann mir da weiterhelfen??

peter

anbei das rekursive
-----------------------
on BearbeiteOrdner(inOrdner)
Ý tell application "Finder"
Ý set theFileList to (every file of inOrdner)
Ý repeat with theFile in theFileList
Ý MachWas() -- hier wird der Handler aufgerufen,
Ý -- der die Arbeit erledigt.
Ý end repeat
Ý set OrdnerListe to every folder of inOrdner
Ý repeat with i from 1 to length of OrdnerListe
Ý my BearbeiteOrdner(item i of OrdnerListe)
Ý end repeat
Ý end tell
end BearbeiteOrdner
---------------------
anbei das eigentliche script, das mir keine unterordner überwacht:
---------------------------------------
-- messages
property sPleaseOpenACatalog : "Bitte öffnen Sie einen Katalog und versuchen es erneut."
property sPleaseChooseAHotFolder : "Bitte wählen Sie den Ordner, der überwacht werden soll!"
property sEnterTimeInterval : "Bitte geben Sie den zeitlichen Intervall für die Überprüfung des Ordners ein!"
property sOnlyOneFolderPlease : "Bitte nur einen Ordner!"
property sFoldersOnlyPlease : "Nur Ordner bitte!"
-----------------------------------------------------------------------------------------
property inFolder : " " -- Incoming files come here
property processedFiles : {} -- processed (cataloged) files go here
property openedAlready : false
property lastModDate : ""
property deltaTime : 60.0 -- seconds
-----------------------------------------------------------------------------------------
on catalogIncomingImages()
-- launch Cumulus
tell application "Cumulus S5.0"
if (count every collection) = 0 then
activate
open (choose file with prompt sPleaseOpenACatalog of type "CuDB")
end if
set filelist to (list folder inFolder without invisibles)
repeat with i from 1 to (count items in filelist)
set theFile to item i of filelist
if processedFiles does not contain theFile then
catalog assets ((inFolder as text) & theFile) to front collection
end if
end repeat
set processedFiles to filelist
end tell
end catalogIncomingImages
-----------------------------------------------------------------------------------------
on getInFolder()
-- check to see if the drop folder is good on this machine
try
set inFolder to alias (inFolder as text)
on error
try
set inFolder to choose folder with prompt sPleaseChooseAHotFolder
on error number errNum
error errNum
end try
end try
end getInFolder
-----------------------------------------------------------------------------------------
on getDeltaTime()
try
set deltaTime to (text returned of (display dialog sEnterTimeInterval default answer (deltaTime as text))) as real
on error errText number errNum
display dialog errText & errNum
end try
end getDeltaTime
-----------------------------------------------------------------------------------------
on idle
if not openedAlready then
try
getInFolder() -- do we have a valid folder yet
set processedFiles to list folder inFolder without invisibles
getDeltaTime()
on error
quit
return deltaTime
end try
set openedAlready to true
set lastModDate to modification date of (info for inFolder)
else
set modDate to modification date of (info for inFolder)
if (modDate - lastModDate) * deltaTime then
set lastModDate to modDate
catalogIncomingImages()
end if
end if
return deltaTime -- check every deltaTime seconds
end idle
-----------------------------------------------------------------------------------------
on run
idle
catalogIncomingImages()
end run
-----------------------------------------------------------------------------------------
on open x
if (count items of (x as list)) > 1 then
display dialog sOnlyOneFolderPlease
else
if last character of (x as text) is ":" then -- we got a folder
set inFolder to x as alias
set processedFiles to list folder inFolder without invisibles
getDeltaTime() -- ask for the delta time
set openedAlready to true
set lastModDate to modification date of (info for inFolder)
else
display dialog sFoldersOnlyPlease
quit
end if
end if
end open
-----------------------------------------------------------------------------------------
on quit
set openedAlready to false
continue quit
end quit
-----------------------------------------------------------------------------------------
_________________
peter senkbeil
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden E-Mail senden Website dieses Benutzers besuchen
Folker
•---->
•---->


Anmeldedatum: 11.12.2000
Beiträge: 649
Wohnort: Holsteinische Schweiz

BeitragVerfasst am: 30.05.2001 - 10:29    Titel: help me Unterordner Antworten mit Zitat

Hallo Peter,

nicht das ich Dein gesamtes Script analysiert hätte (von wegen Anfänger Wink ) - es ist nicht nur lang, ich habe auch keinen Zugriff auf das Programm Cumulus. Einige Worte zu den Möglichkeiten "Unterordner" abzuarbeiten.
Da gibt es zunächst die wirklich tolle Scripting Addition "Jon's Commands" mit dem Befehl "walk folders", welcher Unterordner gleich mit abarbeitet. Die Addition müsstest Du auf folg. Site finden. http://macscripter.net/
Das ganze geht natürlich auch ohne Addition. Folgendes Script habe ich aus den Apple Guide Book Modulen einfach kopiert. http://www.apple.com/applescript/help_mods.html

--SCRIPTANFANG
-- the list of file types which will be processed
property type_list : {}

-- This droplet processes both files or folders of files dropped onto the applet
on open these_items
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items)
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) and ¨
(the file type of the item_info is in the type_list) then
process_item(this_item)
end if
end repeat
end open

-- this sub-routine processes folders
on process_folder(this_folder)
set these_items to list folder this_folder without invisibles
repeat with i from 1 to the count of these_items
set this_item to alias ((this_folder as text) & (item i of these_items))
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) and ¨
(the file type of the item_info is in the type_list) then
process_item(this_item)
end if
end repeat
end process_folder

-- this sub-routine processes files
on process_item(this_item)
-- NOTE that the variable this_item is a file reference in alias format
-- FILE PROCESSING STATEMENTS GOES HERE
end process_item
--SCRIPTENDE

Ich denke das bedarf keines weiteren Kommentars. Ich hoffe es hilft Dir "Neuling" auf die Sprünge.

Gruß
Folker
_________________
Gruß,
Folker Brandt
=============================
Systemberatung · Datenbanken · Webdesign
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden E-Mail senden Website dieses Benutzers besuchen
Beiträge der letzten Zeit anzeigen:   
Dieses Forum ist gesperrt, du kannst keine Beiträge editieren, schreiben oder beantworten.   Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.    Fischer-Bayern.de Foren-Übersicht -> AppleScript-Forum Alle Zeiten sind GMT + 2 Stunden
Seite 1 von 1

 
Gehe zu:  
Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.


Powered by phpBB © 2001, 2002 phpBB Group
Deutsche Übersetzung von phpBB.de


AppleScript für absolute Starter