Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 1, 2009, 09:09 PM   #1
SomeoneElse
macrumors newbie
 
Join Date: Oct 2009
Applescript file duplicate help

I have a script that works but was wondering if I made it incorrect or if it could be improved upon. here is the script and what it does. Simply creates a folder on the current users desktop and places a file named story into it from the folder "test".


-- create a file in Textedit named "Story"
set meow to "Woof Woof"
set CR to ASCII character of 13
tell application "System Events"
tell application "TextEdit" to activate
keystroke "n" using command down -- make new file
keystroke meow & CR & meow & CR & "woof!" & CR -- add some text
keystroke "s" using command down -- save
keystroke "story" & CR
keystroke "q" using command down -- quit
end tell

set the_file to (path to desktop) & "story.rtf" as text
set the_loc to (path to desktop) as text
set new_loc to (path to desktop) & "Test" as text
tell application "Finder"
if (exists (new_loc)) then
else
make new folder at alias the_loc with properties {name:"Test"}

duplicate the_file to new_loc with replacing
end if
duplicate the_file to new_loc with replacing
end tell



This script will create a file named "story" in TextEdit and save it to the desktop"

Next it will copy it to a folder named "test" and if the folder doesn't exist it creates it. and also places the file in the folder if that doesn't exist.

Is this the correct way to do this? Is there an onerr command I could use to better this script?

- SomeoneElse

Last edited by SomeoneElse; Nov 1, 2009 at 09:12 PM. Reason: Esthetic look
SomeoneElse is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Applescript: How do I scan an image to a file? moonman239 Mac Programming 2 May 11, 2014 04:40 PM
Opening a file in AppleScript Chemical666 Mac Programming 2 May 7, 2014 06:47 PM
Formatting text file in AppleScript dam316 Mac Programming 1 May 5, 2014 10:21 AM
Applescript, look after file don't work why? Dirtyharrydev Mac Programming 1 Jan 17, 2014 09:06 PM
applescript differentiate file from folder dancks Mac Programming 2 Jun 30, 2013 07:34 PM

Forum Jump

All times are GMT -5. The time now is 04:19 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC