extracting the path only of a selected file.
Posted: Wed Oct 02, 2013 2:59 am
I am writing a very simple program that allows a user to select a file then in a number of copies field
it will copy the file to the same directory as default but will also allow the user to select a different directory if they wish.
The Gui is simple:
Select file
Display filename only in field of file selected. In directory field put the path of file originally selected.
In the number of copies field which has default of 1
Do it button that copies the file and appends the copy count to original filename so.
Here is the code for my browse button for selecting the file. I don't know how to select the path before the filename.
The part in < > is the command necessary to select all items of path except the last item.
I should know this by now but have not had anytime to play (learn).
on mouseUp
## Ask the user to choose a file
answer file "Please choose a file"
## If the dialog is not cancelled put the path to the selected file into a variable
if the result is not "cancel" then
put it into tFilename
set itemDelimiter to slash
put last item of tFilename into field "file2Dupe"
put <path of original file> tFilename into field "outputDirectory"
end if
end mouseUp
it will copy the file to the same directory as default but will also allow the user to select a different directory if they wish.
The Gui is simple:
Select file
Display filename only in field of file selected. In directory field put the path of file originally selected.
In the number of copies field which has default of 1
Do it button that copies the file and appends the copy count to original filename so.
Here is the code for my browse button for selecting the file. I don't know how to select the path before the filename.
The part in < > is the command necessary to select all items of path except the last item.
I should know this by now but have not had anytime to play (learn).
on mouseUp
## Ask the user to choose a file
answer file "Please choose a file"
## If the dialog is not cancelled put the path to the selected file into a variable
if the result is not "cancel" then
put it into tFilename
set itemDelimiter to slash
put last item of tFilename into field "file2Dupe"
put <path of original file> tFilename into field "outputDirectory"
end if
end mouseUp