Hi! Thank you for your answer. I must have explained myself wrong. It is something else that I want to do. I have a script which I use as an app to create a new text document in every Finder window. So I have an icon there, and by clicking on it, it creates new text document, an another one,.. and another one… doc+1. Like this :
So what I want is renaming the « new text doc » after on cluck on the app icon just like we do it with the « new folder ». It is similar to creating a new txt doc in Windows : I create it, it has a default name and I can rename it. The default name is highlighted so I can change it instantly. Like this:
That is what I want with the text document. On the other hand I want to preserve the possibility to leave the name as it was when created.
My well known code:
tell application "Finder"
try
set fileName to "New text doc"
set thisFolder to the target of the front window as alias
tell application "System Events"
set fileList to get the name of every disk item of thisFolder
end tell
set newFile to fileName
set fileVersion to 1
repeat
if newFile is in fileList then
set newFile to fileName & fileVersion
set fileVersion to fileVersion + 1
else
exit repeat
end if
end repeat
set createdFile to make new file at thisFolder with properties {name:newFile, file type:"TEXT", creator type:"ttxt"}
on error errMsg
display dialog (errMsg)
end try
endtell