Thursday, July 19, 2018

#1 2011-01-13 12:42:48 pm

May's-Magic-Fingers
Member
From:: australia
Registered: 2010-12-07
Posts: 37
Website

new project

hi i am new to applescript studio and i am starting whit something simple.
im making an app to help me whit school. i would like it to copy a file or mack one.
theres screenshots might help
newprject1 http://may19c19.deviantart.com/#/d3736z4
newprject2 http://may19c19.deviantart.com/#/d37370q
newprject3 http://may19c19.deviantart.com/#/d373a9k
newprject4 http://may19c19.deviantart.com/#/d373ac5

Offline

 

#2 2011-01-14 06:35:43 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2777
Website

Re: new project

Those folders you want to copy are all empty in your screenshot. So why not creating the structure.

For example a code like this

Applescript:


--I've written this function in the browser so it isn't tested for correct syntax
on createNewProject()
set pathToClasses to "~/Desktop/Work/school/uncompleted projects/"
set projectName to content of text field "name" of window "main" --I don't now your window name
set theParentFolder to title of popup button "class" of window "main"
if length of projectName is 0 then
return
end
set pathToProject to pathtoclasses & theParentFolder & "/" & projectname & "/" as string
if not ((do shell script "test -e " & quoted form of pathToProject & "; echo $?") as integer) as boolean then
--file already exists
return
end if

do shell script "mkdir " & quoted form of (pathToProject & "drafts")
do shell script "mkdir " & quoted form of (pathToProject & "notes")
do shell script "mkdir " & quoted form of (pathToProject & "resorces") --shouldn't it be resources?
do shell script "mkdir " & quoted form of (pathToProject & "resorces/notes")
do shell script "mkdir " & quoted form of (pathToProject & "resorces/pics")
end

Last edited by DJ Bazzie Wazzie (2011-01-14 06:36:35 am)

Offline

 

#3 2011-01-14 01:14:11 pm

May's-Magic-Fingers
Member
From:: australia
Registered: 2010-12-07
Posts: 37
Website

Re: new project

my window name is "window 1" as i have no need to change it.
i think u need to make new folder at folder theParentFolder of pathToClasses with properties {name: projectName} because the folder projectname of [pathToProject to pathtoclasses & theParentFolder & "/" & projectname & "/" ] has not been mad i think if it has im sorry i can not find what line u make it.
and yes should it be resources i have bad spelling

Offline

 

#4 2011-01-14 01:29:26 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11499
Website

Re: new project

DJ Bazzie Wazzie wrote:

Applescript:


…
do shell script "mkdir " & quoted form of (pathToProject & "drafts")
do shell script "mkdir " & quoted form of (pathToProject & "notes")
do shell script "mkdir " & quoted form of (pathToProject & "resorces") --shouldn't it be resources?
do shell script "mkdir " & quoted form of (pathToProject & "resorces/notes")
do shell script "mkdir " & quoted form of (pathToProject & "resorces/pics")
…


mkdir provides a smart way to create directory hierarchies

Applescript:

do shell script "mkdir -p " & quoted form of pathToProject & "/{drafts,notes,resources/{notes,pics}}"

the -p switch creates intermediate directories silently


regards

Stefan

Offline

 

#5 2011-01-14 01:58:45 pm

May's-Magic-Fingers
Member
From:: australia
Registered: 2010-12-07
Posts: 37
Website

Re: new project

ok thanks StefanK i did not know that.
why dues the script not work then? i do not know.

Offline

 

#6 2011-01-19 10:28:51 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2777
Website

Re: new project

May's-Magic-Fingers wrote:

i think u need to make new folder at folder theParentFolder of pathToClasses with properties {name: projectName} because the folder projectname of [pathToProject to pathtoclasses & theParentFolder & "/" & projectname & "/" ] has not been mad i think if it has im sorry i can not find what line u make it.


sorry for late response but the last 1 or two days macscripter was offline. What I did (and stefan's solution even better) was creating directories/folders in a shell and not in the Finder. The syntax you're asking for is for scripting the Finder. Also I prefer for an application that it's not depended on the Finder and more depended on the shell. So your application can't provide the finder a beachball nor can a hanging Finder freeze your application. It's just a preference for myself to make applications less depended on other applications including the Finder.

Like I said reading your question you're using a Finder syntax and not a shell. The finder provides some events to create a new folder but the Finder works with macintosh/hfs paths and not with posix paths. This means that path to classes needs to be

Applescript:

set pathToClasses to (path to desktop folder as string) & "Work:school:uncompleted projects:"

setting projectFolder must be

Applescript:

set pathToProject to pathtoclasses & theParentFolder & ":" & projectname & ":" as string

delete the shell commands (including the check for existance) and replace it with this to create the folder

Applescript:

tell application "Finder"
make new folder at folder pathToProject with properties {name:"drafts"}
make new folder at folder pathToProject with properties {name:"notes"}
set resourceFolder to make new folder at folder pathToProject with properties {name:"resources"}
make new folder at folder resourceFolder with properties {name:"notes"}
make new folder at folder resourceFolder with properties {name:"pics"}
end tell

Last edited by DJ Bazzie Wazzie (2011-01-20 11:05:32 am)

Offline

 

#7 2011-01-20 10:25:50 am

May's-Magic-Fingers
Member
From:: australia
Registered: 2010-12-07
Posts: 37
Website

Re: new project

thankks helps alot big_smile

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)