how can i have my program copy and paste an image file

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

how can i have my program copy and paste an image file

Post by magice » Sun Apr 12, 2009 11:19 pm

Lets say i have an image file. It is at C:\Documents and Settings\Admin\Desktop\sample.jpg . I want to have my program copy and save it to a new location with a new name e.g. docs\images\newname.jpg. I want it all done behind the scenes without the end users input. What is the easiest way?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10049
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Mon Apr 13, 2009 3:01 am

Your thread title and message content describe two very different tasks.

If indeed all you want to do is move a file, the "rename file" command can change any elements of a file's path:

rename folder "C:/Documents and Settings/Admin/Desktop/sample.jpg" \
to "/docs/mages/newname.jpg"
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Post by magice » Mon Apr 13, 2009 3:42 am

I tried that, however I don't want to remove the original file. instead I want to make a new copy in a new location. I think I might have found the answer though in the revCopyFile command. I just need to get it to work from inside a do command since the locations will be stored in variables. At least I feel like I am on the right track. Thank you

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10049
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Mon Apr 13, 2009 7:09 am

put "/myfolder/myfile.jpg" into tSrcFile
put /myotherfolder/mynewfile.jpg" into tNewFile
put url ("binfile:"& tSrcFile) into url ("binfile:"&tNewFile)
if the result is not empty then
answer "Something went wrong with the file copy: "& sysError()
else
answer "File copied well. Nifty, eh?" with "Cool"
end if
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply