hey how do i get the parent directory name of a file.
Like on the tree
/myfilesfolder/file.txt
if i have file.txt as my_file, how do i get myfilesfolder – just the name – as a string?
hey how do i get the parent directory name of a file.
Like on the tree
/myfilesfolder/file.txt
if i have file.txt as my_file, how do i get myfilesfolder – just the name – as a string?
tell application "Finder"
set theFile to choose file
set theParent to name of container of theFile
end tell
on open of target_files
repeat with the_file in the target_files
set the_filename to the name of (info for the_file)
set the_filepath to the POSIX path of the_file
set the_folder to ""
tell application "Finder"
set the_folder to the folder of the_file
display dialog the name of the_folder -- this doesnt work.
end tell
end repeat
end open
see where i commented. it doesnt work.
i even tried to use container.
or with text item delimiters
on open of target_files
set {TID, text item delimiters} to {text item delimiters, ":"}
repeat with the_file in the target_files
display dialog text item -2 of (the_file as text)
end repeat
set text item delimiters to TID
end open
your original script works this way
on open of target_files
repeat with the_file in the target_files
set the_filename to the name of (info for the_file)
set the_filepath to the POSIX path of the_file
set the_folder to ""
tell application "Finder"
set the_folder to the container of the_file
display dialog (get name of the_folder) -- this works.
end tell
end repeat
end open