Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 7, 2012, 06:42 PM   #1
CountrySeacow
macrumors newbie
 
Join Date: Dec 2012
ApplescriptEditor; Renaming folders

Hello applescript users!
There is most likely a very simple answer to this, but i cannot find code that allows you to tell applescript to change the name of "FolderA" to "BFolder" (as an example).
Here is a sample scenario that i want to use it in:
Code:
tell application "Finder"
	activate
	if exists folder "Macintosh HD:Users:USERNAME:Library:Application Support:FolderA" then
--(*rename "FolderA" to "BFolder"*)
	else
--(*ETC*)
	end if
end tell
Where
-- (*TEXTHERE*)
is just there to note what i want there. The (*ETC*) is other code that is unnecessary in the scenario.
Thanks everyone!
CountrySeacow
CountrySeacow is offline   0 Reply With Quote
Old Dec 7, 2012, 08:46 PM   #2
andmr
macrumors member
 
Join Date: Aug 2008
Location: NE Florida
Hi, try this:

Code:
tell application "Finder"
	set x to "Macintosh HD:Users:USERNAME:Library:Application Support:FolderA"
	if exists folder x then
		set name of folder x to "BFolder"
	else
		--(*ETC*)
	end if
end tell
andmr is offline   0 Reply With Quote
Old Dec 8, 2012, 11:44 AM   #3
CountrySeacow
Thread Starter
macrumors newbie
 
Join Date: Dec 2012
Quote:
Originally Posted by andmr View Post
Hi, try this:

Code:
tell application "Finder"
	set x to "Macintosh HD:Users:USERNAME:Library:Application Support:FolderA"
	if exists folder x then
		set name of folder x to "BFolder"
	else
		--(*ETC*)
	end if
end tell
hmm. I dont know if the "set name to" function for that works because it cant find the folder, even though it exists.
I tried using the following code, with "FolderA" present on the desktop
Code:
tell application "Finder"
	set x to "Macintosh HD:Users:USERNAME:Desktop:FolderA"
	if exists folder x then
		set name of folder x to "BFolder"
	else
		display dialog "it doesnt exist"
	end if
end tell
any advice?
it will either tell my it cant make "Macintosh HD:Users:USERNAME:Desktop:FolderA" into type, or it will say "it doesnt exist"

Last edited by CountrySeacow; Dec 9, 2012 at 02:44 PM.
CountrySeacow is offline   0 Reply With Quote
Old Dec 9, 2012, 04:10 PM   #4
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Try this :

Code:
tell application "Finder"
	set x to (path to desktop as text) & "FolderA"
	if exists folder x then
		set name of folder x to "BFolder"
	else
		display dialog "it doesnt exist"
	end if
end tell
Post a screenshot of the Event Log when you run the script in the Script Editor.
Attached Thumbnails
Click image for larger version

Name:	Picture 3.png
Views:	7
Size:	17.9 KB
ID:	382534  
__________________
Space Corps Directive 34124
kryten2 is online now   0 Reply With Quote
Old Dec 9, 2012, 05:29 PM   #5
CountrySeacow
Thread Starter
macrumors newbie
 
Join Date: Dec 2012
Quote:
Originally Posted by kryten2 View Post
Try this :

Code:
tell application "Finder"
	set x to (path to desktop as text) & "FolderA"
	if exists folder x then
		set name of folder x to "BFolder"
	else
		display dialog "it doesnt exist"
	end if
end tell
Post a screenshot of the Event Log when you run the script in the Script Editor.
YAY! Yours worked!!! Thanks!
Hey, does that "(path to desktop as text) & "FolderA"" apply when ever you are trying to connect to the desktop? I have another thread on that.
Here my other thread:
http://forums.macrumors.com/showthread.php?t=1503702
Thanks again!
CountrySeacow is offline   0 Reply With Quote
Old Dec 9, 2012, 05:53 PM   #6
CountrySeacow
Thread Starter
macrumors newbie
 
Join Date: Dec 2012
Quote:
Originally Posted by kryten2 View Post
Try this :

Code:
tell application "Finder"
	set x to (path to desktop as text) & "FolderA"
	if exists folder x then
		set name of folder x to "BFolder"
	else
		display dialog "it doesnt exist"
	end if
end tell
Post a screenshot of the Event Log when you run the script in the Script Editor.
Alright, question for you kryten2. What if i want to reference the ApplicationSupport folder using "(path to desktop as text) & "FolderA""
CountrySeacow is offline   0 Reply With Quote
Old Dec 10, 2012, 03:48 PM   #7
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Hey, does that "(path to desktop as text) apply when ever you are trying to connect to the desktop?
Yes

Quote:
What if i want to reference the ApplicationSupport folder
Depends on which Application Support folder you want to reference :

Code:
path to application support from user domain
path to application support from local domain
Info : https://developer.apple.com/library/...983-CH216-SW18
Attached Thumbnails
Click image for larger version

Name:	Picture 4.png
Views:	9
Size:	59.7 KB
ID:	382771  
__________________
Space Corps Directive 34124
kryten2 is online now   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
I just transferred some folders onto my external hardrive. A couple of the folders ha katieee28 iMac 2 Apr 11, 2014 02:13 AM
forklift users-renaming files/folders mrjayviper Mac Applications and Mac App Store 1 Mar 2, 2014 11:52 AM
help with better finder rename (renaming various folders) mrjayviper Mac Applications and Mac App Store 1 Jan 20, 2014 06:13 AM
Renaming folders in Terminal supertonic Mac Programming 6 Jun 29, 2013 12:16 PM
Outlook 2011 for Mac Offline Folders to Exchange Folders meymetkaplan Mac Applications and Mac App Store 0 Jan 23, 2013 08:34 AM

Forum Jump

All times are GMT -5. The time now is 01:42 PM.

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

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