I have searched in this forum but have not find anything that helps me.
I just want all file names in a specific folder (and subfolders) saved to a text file. Thats easy.
But also (and this is the tricky part) the file pathes saved after the file names. Like this example:
(The file path before the file name is also an option)
birds.qxp:ANIMALS:Macintosh HD
eagle.jpg:BIRDS:IMAGES:ANIMALS:Macintosh HD
duck.jpg:BIRDS:IMAGES:ANIMALS:Macintosh HD
colibri.jpg:SMALL BIRDS:BIRDS:IMAGES:ANIMALS:Macintosh HD
dogs.qxp:ANIMALS:Macintosh HD
Siberian Husky.jpg:DOGS:IMAGES:ANIMALS:Macintosh HD
Yorkshire Terrier.jpg:DOGS:IMAGES:ANIMALS:Macintosh HD
Doberman Pinscher.jpg:BIG DOGS:DOGS:IMAGES:ANIMALS:Macintosh HD
to saveText from t to n
set f to choose file name with prompt "Save summary file as:" default name n & " summary.txt"
set o to open for access f with write permission
set eof o to 0
write t to o
close access o
end saveText
on summaryData()
set f to choose folder with prompt "Choose a folder to summarise:"
set d to text item delimiters
set text item delimiters to return
tell application "Finder" to set {n, t} to {f's name, paragraphs of (files of f's entire contents as Unicode text)}
set text item delimiters to ":"
repeat with i from 1 to count t
tell reverse of t's item i's text items to set t's item i to beginning & ({""} & rest)
end repeat
set text item delimiters to return
tell t to set t to beginning & ({""} & rest)
set text item delimiters to d
{t, n}
end summaryData
tell summaryData() to my (saveText from item 1 to item 2)
property summaryFolder : alias "full:path:to:folder:to:summarise:"
property summaryFile : alias "full:path:to:summary:file"
to saveText from t
set o to open for access summaryFile with write permission
set eof o to 0
write t to o
close access o
end saveText
on summaryData()
set d to text item delimiters
set text item delimiters to return
tell application "Finder" to set t to paragraphs of (files of summaryFolder's entire contents as Unicode text)
set text item delimiters to ":"
repeat with i from 1 to count t
tell reverse of t's item i's text items to set t's item i to beginning & ({""} & rest)
end repeat
set text item delimiters to return
tell t to set t to beginning & ({""} & rest)
set text item delimiters to d
t
end summaryData
saveText from summaryData()