Re: Index a given folder
Re: Index a given folder
- Subject: Re: Index a given folder
- From: "Stockly, Ed" <email@hidden>
- Date: Wed, 7 Apr 2010 18:47:41 -0500
- Acceptlanguage: en-US
- Thread-topic: Index a given folder
> 1. be pointed to a chosen folder,
>
> 2. will get the names of every file in that folder,
>
> 3. generate a text file which lists all the files in that folder
> (order doesn't really matter, but alphabetical would be nice), and
>
> 4. save the text file to Desktop.
Try this:
HTH
ES
set myFolder to choose folder
open {myFolder}
on open folderList
repeat with thisFolder in folderList
set folderPath to thisFolder as text
if the last character of folderPath is ":" then
tell application "System Events"
set folderName to name of thisFolder
set fileName to "item names from " & folderName & ".txt"
set newFile to folderPath & fileName
set itemNames to the name of every item of thisFolder as
list
end tell
set AppleScript's text item delimiters to {return}
set fileText to itemNames as text
my OpenWriteClose(newFile, fileText)
end if
end repeat
end open
on OpenWriteClose(myFile, myText)
try
set openFile to (open for access myFile with write permission)
on error
close access openFile
set openFile to (open for access myFile with write permission)
end try
set eof of openFile to 0
write myText to openFile
close access openFile
end OpenWriteClose
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden