New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

Applescript troubleshooting


Post Reply New Thread Subscribe

 
Thread Tools
TSMIIINOLA

 
Member Since: Jul 12, 2011
Posts: 2
TSMIIINOLA is on a distinguished road

TSMIIINOLA is offline
I have a folder of 258 excel files that are sorted alphabetically. I would like to run a script that renames all of the files based on excel values. I wrote a script that does a similar action, but to add new folders based on excel content. I tried to adapt it, but I was unsuccessful. Can anyone help?
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 18,009
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is online now
Can you post the script? It's likely that it can be adapted with some minor changes.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
TSMIIINOLA

 
Member Since: Jul 12, 2011
Posts: 2
TSMIIINOLA is on a distinguished road

TSMIIINOLA is offline
set theFiles to choose file with multiple selections allowed
set theCount to number of items in theFiles
repeat with i from 1 to theCount
tell application "Microsoft Excel"
set theCells to value of range "a1:a71" of active sheet
end tell
repeat with onecell in theCells

tell application "Finder"


set name of file (item i of theFiles) to (item 1 of onecell)

end tell
end repeat
end repeat
QUOTE Thanks
MacGrunt

 
MacGrunt's Avatar
 
Member Since: Aug 02, 2011
Posts: 17
MacGrunt is on a distinguished road

MacGrunt is offline
G'day

I'm assuming you are trying to rename a bunch of files using one open excel spreadsheet as the source of the filenames and that the new filenames are in column A (?)

Code:
set theFiles to choose file with multiple selections allowed
set NewNames to {}

--place enough values from excel file into a list
tell application "Microsoft Excel"
	tell active sheet of active workbook
		repeat with x from 1 to count of theFiles
			set end of NewNames to formula of cell ("A" & x)
		end repeat
	end tell
end tell
--rename the files
repeat with i from 1 to count of theFiles
	set NewName to item i of NewNames
	set ThisFile to item i of theFiles
	tell application "Finder"
		set name of ThisFile to (NewName & "." & name extension of ThisFile)
	end tell
end repeat
i haven't tested what will happen if the script runs into an empty cell.

you could also run this as a droplet instead by changing it like this :
Code:
on open theFiles
	-- delete the following line
	set theFiles to choose file with multiple selections allowed
	--add the rest of the script
end open
hope that helps a little

m.
QUOTE Thanks

Post Reply New Thread Subscribe


« Bought a new hard drive, will i need a new OS cd? | time capsule question »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Applescript help with serial port access ljimber OS X - Development and Darwin 0 06-24-2011 11:46 AM
help needed to link up buttons on HUD Window to Applescript nick_harambee OS X - Development and Darwin 0 09-30-2010 08:26 AM
newbie question on XCode 3.2: how to populate pop up buttons/link to applescript nickharambee OS X - Operating System 0 10-21-2009 07:10 AM
Logic Express and Applescript via GUI Scripting albertaurus Music, Audio, and Podcasting 0 04-09-2009 01:13 PM
[ANN] New comprehensive AppleScript book hanaan OS X - Development and Darwin 0 11-06-2004 07:28 PM

All times are GMT -4. The time now is 09:41 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?