Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iW00t

macrumors 68040
Original poster
Nov 7, 2006
3,286
0
Defenders of Apple Guild
Hi,

I really need to get an Applescript book at some point.

How do I create a file in a particular folder (ie: ~/tmp) and then subsequently check the existence of said file and delete it if it is present?
 

lancestraz

macrumors 6502a
Nov 27, 2005
898
0
RI
Maybe this will help.

Edit: Oh, you said "file". I though you said "folder". What kind of file?

Code:
set the_path to (path to desktop as string) -- Set the folder you want to create your folder in
set folder_name to "test_folder" -- Give you new folder a name
set the_folder to (the_path & folder_name & ":") -- Now combine the name and the path to make it easier to reference latter on

tell application "Finder"
	if (exists the_folder) is false then -- Check to see it the folder exists
		make new folder at the_path with properties {name:folder_name}
		delete the_folder
	end if
end tell
 

iW00t

macrumors 68040
Original poster
Nov 7, 2006
3,286
0
Defenders of Apple Guild
It is just a dummy 0 byte file that is created by an earlier script to indicator that a process has taken place.

Now here is for another really noobish question, how do you actually traverse through a list variable?
 

lancestraz

macrumors 6502a
Nov 27, 2005
898
0
RI
It is just a dummy 0 byte file that is created by an earlier script to indicator that a process has taken place.
Does this file have an extension?

Now here is for another really noobish question, how do you actually traverse through a list variable?
Like this.
Code:
set the_list to {"Item One", "Item Two", "Item Three"} -- Define your list

repeat with i from 1 to number of items in the_list
	set this_item to item i of the the_list -- Set "this_iten" to the next item in the list
	display dialog this_item
end repeat
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.