Results 1 to 4 of 4
  1. #1
    Applescript troubleshooting

    Member Since
    Jul 12, 2011
    Posts
    2
    Applescript troubleshooting
    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?

  2. #2
    Applescript troubleshooting
    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,395
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  3. #3
    Applescript troubleshooting

    Member Since
    Jul 12, 2011
    Posts
    2
    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

  4. #4
    Applescript troubleshooting
    MacGrunt's Avatar
    Member Since
    Aug 02, 2011
    Posts
    16
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. startup troubleshooting
    By guyatwork in forum Apple Notebooks
    Replies: 2
    Last Post: 01-23-2012, 03:34 PM
  2. Macbook troubleshooting
    By Jesus in forum Apple Notebooks
    Replies: 0
    Last Post: 12-27-2010, 01:52 AM
  3. Need help troubleshooting
    By Kev_McCall in forum Apple Notebooks
    Replies: 1
    Last Post: 02-05-2010, 04:15 PM
  4. standard troubleshooting
    By Smackintosh in forum OS X - Operating System
    Replies: 0
    Last Post: 02-15-2007, 10:00 AM
  5. Troubleshooting the MacBook
    By jram in forum Apple Notebooks
    Replies: 2
    Last Post: 06-17-2006, 12:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •