Page 1 of 1
Copy a pdf
Posted: Tue Sep 15, 2015 7:23 am
by shalu
Hi
I am beginner in LiveCode. I am looking for the code of copy a pdf from tmp to some other folder, if the pdf is alrady in that folder then it's must be renamed as pdfname1.pdf if I am agin copy the same pdf then it's must be pdfname2.pdf. is it possible
Thanks
Shalu
Re: Copy a pdf
Posted: Tue Sep 15, 2015 9:45 am
by jmburnod
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
Re: Copy a pdf
Posted: Tue Sep 15, 2015 10:13 am
by shalu
Hi jmburnod,
Thank you for your reply, it's working
Thanks
Shalu