Copy a pdf

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Copy a pdf

Post by shalu » Tue Sep 15, 2015 7:23 am

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 :roll:

Thanks
Shalu
--
Thanks
Shalu S

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Copy a pdf

Post by jmburnod » Tue Sep 15, 2015 9:45 am

Hi Shalu,
is it possible
Yes :D

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
https://alternatic.ch

shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Re: Copy a pdf

Post by shalu » Tue Sep 15, 2015 10:13 am

Hi jmburnod,

Thank you for your reply, it's working :) :lol: :D

Thanks
Shalu
--
Thanks
Shalu S

Post Reply