I would like to write a program, which processes qxd-files as batch-listed.
the “drag files to the list”-function runs, but i have problems with dragged folders…
How can i list the files from a dragged folder with subfolders!
Please help me!
Many thanks…
on awake from nib theObject
if name of theObject is "fileList" then
-- Create the data source for the table view
set theDataSource to make new data source at end of every data source with properties {name:"files"}
-- Create the "files" data column
make new data column at end of every data column of theDataSource with properties {name:"fileList"}
-- Assign the data source to the table view
set data source of theObject to theDataSource
set selected data column of theObject to item 1 of every data column of theDataSource
-- Register for the "color" and "file names" drag types
tell theObject to register drag types {"file names"}
end if
end awake from nib
-- The "drop" event handler is called when the appropriate type of data is dropped onto the object.
--All of the pertinent information about the drop is contained in the "dragInfo" object.
--
on drop theObject drag info dragInfo
-- Get the list of data types on the pasteboard
set dataTypes to types of pasteboard of dragInfo
-- We are only interested in either "file names" or "color" data types
if "file names" is in dataTypes then
-- Initialize the list of files to an empty list
set theFiles to {}
-- We want the data as a list of file names, so set the preferred type to "file names"
set preferred type of pasteboard of dragInfo to "file names"
-- Get the list of files from the pasteboard
set theFiles to contents of pasteboard of dragInfo
addFilesToList(theFiles, theObject)
end if
-- Set the preferred type back to the default
set preferred type of pasteboard of dragInfo to ""
return true
end drop
on addFilesToList(theFiles, theTable)
-- Make sure we have at least one item
if (count of theFiles) > 0 then
--- Get the data source from the table view
set theDataSource to data source of theTable
-- Turn off the updating of the views
set update views of theDataSource to false
-- Delete all of the data rows in the data source
--delete every data row of theDataSource
-- For every item in the list, make a new data row and set it's contents
--repeat with theItem in theFiles
repeat with theName in theFiles
--set addItem to false
try
set theFile to POSIX file theName
on error
set theFile to theName
end try
set item_info to info for theFile
set fcreator to file creator of item_info
tell application "Finder" to set ftype to file type of item_info
set fext to name extension of item_info
set isFolder to folder of item_info
if (isFolder) then
-- we'd like to process folders too
set theDataRow to make new data row at end of every data row of theDataSource
set folderName to (theFile as text) & ":"
set contents of data cell "fileList" of theDataRow to folderName
end if
if ((ftype is in the typesList) or (fext is in the extensionsList) or ¬
(fcreator is in the creatorsList)) then
set itemsAdded to true
--set addItem to true
set theDataRow to make new data row at end of every data row of theDataSource
set contents of data cell "fileList" of theDataRow to (theFile as text)
end if
end repeat
set selected data row of theTable to item 1 of every data row of theDataSource
--set selected data column of theTable to item 1 of data columns of theDataSource
-- Turn back on the updating of the views
set update views of theDataSource to true
end if
end addFilesToList
on open theFiles
set theTable to table view "fileList" of scroll view "fileList" of window "main"
addFilesToList(theFiles, theTable)
end open