Allright,
extreme newbie question;
I’m working on a project and everything else works swimingly except for this. I need to set the value of a variable to the name of a file located within a specific folder. I know this should be easy, but every time I try it, the value end up being the entire path to said file…
Ideas? Thanks…
Rob
March 19, 2003, 3:57am
#2
Allright,
extreme newbie question;
I’m working on a project and everything else works swimingly except for this. I need to set the value of a variable to the name of a file located within a specific folder. I know this should be easy, but every time I try it, the value end up being the entire path to said file…
Ideas? Thanks…
set targetFile to choose file
tell application "Finder" to set fileName to name of targetFile
display dialog fileName
I’m sorry, I didn’t make myself clear. The file name, and location will be static, so I want the script to be able to do this automatically.
Rob
March 19, 2003, 3:07pm
#4
I’m sorry, I didn’t make myself clear. The file name, and location will be static, so I want the script to be able to do this automatically.
Maybe it would be easier if you provide the bit of code that’s giving you problems.
True… hehehe.
tell app "Finder"
set myName to the first file of folder "XYZ" of disk "ABC"
display dialog "The File Name is " & (myName)
end tell
Does that make it any clearer? When the script is run, instead of just returning the name of the file in the specified folder, it returns the entire path. “The File Name is ABC:XYZ:Filename”
Ideas as to what I’m doing wrong?
Rob
March 19, 2003, 3:46pm
#6
True… hehehe.
tell app "Finder"
set myName to the first file of folder "XYZ" of disk "ABC"
display dialog "The File Name is " & (myName)
end tell
Does that make it any clearer? When the script is run, instead of just returning the name of the file in the specified folder, it returns the entire path. “The File Name is ABC:XYZ:Filename”
Ideas as to what I’m doing wrong?
Yep, that helps a lot. The script is asking for the file and not the name of the file.
Does this work?
tell app "Finder"
set myName to name of the first file of folder "XYZ" of disk "ABC"
display dialog "The File Name is " & (myName)
end tell
Yep, that helps a lot. The script is asking for the file and not the name of the file.
Does this work?
tell app "Finder"
set myName to name of the first file of folder "XYZ" of disk "ABC"
display dialog "The File Name is " & (myName)
end tell
Argh… yes, that was it! So simple. smacks self in forhead Thanks for your help!!