Hi Shalu,
is it possible
Yes
There is two parts in your post
How to copy a pdf file ?
You have to use binfile for a pdf
How to rename as pdfname.pdf ?
The NextTitreFile() function return a new path "pdfname_+1.pdf" if file exists
Best regards
Jean-Marc
Code: Select all
on mouseUp
answer file "Select file :"
if it = empty then exit mouseUp
put it into tPathS
set the itemdel to "/"
put item -1 of tPathS into tNameFile
set the itemdel to ","
answer folder "Select a destination folder"
if it = empty then exit mouseUp
put it into tFolD
put tFolD & "/" & tNameFile into tPathD
if there is a file tPathD then
put NextTitreFile(tFolD,tNameFile) into tPathD
end if
put url("binfile:" & tPathS) into url("binfile:" & tPathD)
end mouseUp
function NextTitreFile pFol,pFile
put empty into rNextTitreFile
set the itemdel to "."
put item 1 of pFile into tName
put item 2 of pFile into tSuff
if "_" is in tName then --••
put offset("_",tName) into tOff
delete char tOff to -1 of tName
end if
put 0 into tCount
repeat until tExists = false
add 1 to tCount
if char -1 of pFol <> "/" then
put "/" after pFol
end if
put pFol & tName & "_" & tCount & "." & tSuff into tPath
if there is not a file tPath then
put tPath into rNextTitreFile
exit repeat
end if
end repeat
return rNextTitreFile
end NextTitreFile