Export Folder contents to .txt?

have been trying to do a small applescript that could retrieve filename + date created / date modified onto a text file or somekind of output. Its pretty basic and I have found some interesting ideas, this is as far as I got…

tell application “Finder”
set file_list to creation date of every file of entire contents of (choose folder with prompt “Please select directory.”)
end tell

as you can imagine am pretty new at this; all that works well, as a result i get something similar to this…

{date “Monday, 22 October 2012 16:44:25”, date “Monday, 22 October 2012 16:44:31”}

Unfortunatley I dont know how to inlude the filename in the string and more than anything how to place the results into a text file, on that side I found this string quite interesting…

tell application “TextEdit”
activate
make new document
set text of document 1 to theDate as text
save document 1 in “path”
end tell
end tell

Its not entirely right, I think, the idea is for that file to be named after the actual date; plus the ideal scenario would be the user being able to choose the destination of that text file, I have been trying so few things but seems to be one of those really simple things that are right in front of your nose so…you just can’t see them.

I would really appreciatte your help guys…

D.

Model: imac 27
AppleScript: 2.4.3
Browser: Safari 536.26.14
Operating System: Mac OS X (10.7)

Welcome to the forum.

Try this:


set textLocation to quoted form of (POSIX path of (path to desktop as text) & "myText.txt")
tell application "Finder" to set file_list to every file of entire contents of (choose folder with prompt "Please select directory.")
set finalList to {"File Name", "|", "Creation Date", return}
repeat with aFile in file_list
	tell application "System Events" to set end of finalList to aFile's name & "|" & aFile's creation date & return
end repeat
do shell script "echo " & quoted form of (finalList as text) & " > " & textLocation

Here is one that I used but it’s not as efficient as the previously posted version.



tell application "Finder"
	
	--all items including files and folders will be listed alphabetically
	
	choose folder with prompt "Pick a folder to list:"
	set myFolder to result
	
	set myList to name of every item of myFolder
	
	set myFile to make new file at desktop with properties {name:"Files.txt"}
	
	write return to (myFile as alias)
	repeat with i in myList
		write (i as string) & return & return to (myFile as alias) starting at -1
	end repeat
	beep
end tell