STUCK Renaming files with Sequential Letters - NOT Numbers

:cry:

This board is the bomb - I’ve managed to munge together a script that processes photos from my Camera, and it works fine. It appends 01, 02, 03 etc to the name of the shot. I’d like to append a, b, c etc to the names: I’m stuck!

This works with numbers now:

		repeat with i from 1 to count of NewShotList
			
			set theName to name of item i of NewShotList
			if theName contains "." then
				set nameSuffix to (text -1 thru ¬
					(offset of "." in theName) of theName)
			else
				set nameSuffix to ""
			end if
			
			set name of item i of NewShotList to ¬
				mo & "" & da & "-" & ItemNumber & "-" & (text -2 thru -1 of ¬
				("0" & i)) & nameSuffix
		end repeat

I’ve tried to use:


		set LastLetter to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"}
		
		repeat with i from 1 to count of NewShotList
			
			set theName to name of item i of NewShotList
			if theName contains "." then
				set nameSuffix to (text -1 thru ¬
					(offset of "." in theName) of theName)
			else
				set nameSuffix to ""
			end if
			
			set name of item i of NewShotList to ¬
				mo & "" & da & "-" & ItemNumber & ¬
				(i of LastLetter) & nameSuffix
		end repeat

with NO success. Any assistance is appreciated.

From what i understoof you have several files in a folder called ‘foo.01’, ? , ‘foo.08’,?
The following peiece of code might help you.


set desktoppath to path to desktop as string

set LastLetter to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"}
}
repeat with i from 1 to count of NewShotList
	tell application "Finder"
		set currentItem to name of (item i of NewShotList)
		set DotOffset to offset of "." in currentItem
		set finalname to (items 1 thru DotOffset of currentItem as text) & (item i of LastLetter) as text
		set name of (item i of NewShotList) to finalname
	end tell
end repeat

JBLS: :smiley:

It didn’t work out of the box, but I was able to do a little more munging to get it working like I like.

Here’s the final script that works:


on open NewShotList
	--where do these shots go?	
	set NewFolderPath to "BIG_OWC:work:yesterdaywonder:tias:TiasSalePhotos"
	--Get the item name
	set NewThing to "What Is This Thing?"
	set NewItemName to ¬
		(display dialog "What's the New Item?:" default answer NewThing)
	set the NewItem to the text returned of NewItemName
	--Now Assign a 2-digit Number
	set the NewThingNumber to "Now Gimme This Thing's Number?"
	set the NewItemNumber to ¬
		(display dialog "What is it's Item Number:" default answer NewThingNumber)
	set the ItemNumber to the text returned of NewItemNumber
	
	-- this is the date stuff. don't mess with the date stuff
	-- the date stuff was posted by Ben Lawson on 
	-- http://www.macadillo.com/ATW/coolcode.html
	-- and modified by rich graham to get the MMDD format
	-- on 021018
	
	copy ((offset of (the month of (current date)) in ¬
		"jan feb mar apr may jun jul aug sep oct nov dec ") + 3) / 4 ¬
		as integer to mo
	if mo < 10 then copy "0" & mo as string to mo
	copy day of (current date) to da
	if (day of (current date) < 10) then copy "0" & da as string to da
	copy mo & "" & da & "-" & ItemNumber & "_" & NewItem to NewItemFolder
	
	-- the date stuff ends, but the folder-making and file naming stuff begins.
	--I make a New Folder Named with the MM/DD DATE CODE, THE NUMBER, AND THE NAME
	
	tell application "Finder"
		set the MyNewItemFolder to make new folder at folder NewFolderPath with properties {name:NewItemFolder, expanded:true}
		set NewItemFolder to MyNewItemFolder as text
		move every item of selection to container NewItemFolder
	end tell
	
	--I move all the shots to that folder, naming them with the date code & item number & alpha last letter 
	--(the Alpha letter at the end is required to be compliant with TIAS, so ebay items will show up and TIAS)
	
	tell application "Finder"
		activate
		set NewShotList to every file of container NewItemFolder
		set LastLetter to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"}
		repeat with i from 1 to count of NewShotList
			set theName to name of item i of NewShotList
			if theName contains "." then
				set nameSuffix to (text -1 thru ¬
					(offset of "." in theName) of theName)
			else
				set nameSuffix to ""
			end if
			
			set name of item i of NewShotList to ¬
				mo & "" & da & "-" & ItemNumber & ¬
				(item i of LastLetter) & nameSuffix
		end repeat
		
		--I retreive a blank eLister template file, and name it properly as well, using above data
		
		copy file "eBayTemp.els" of folder "eLister 2.1" of folder "Auction Stuff" of folder ¬
			"yesterdaywonder" of folder "work" of disk "BIG_OWC" to folder NewItemFolder
		set name of file "eBayTemp.els" of folder NewItemFolder to ¬
			mo & "" & da & "-" & ItemNumber & NewItem & ".els"
		
		beep
		beep
	end tell
end open

For anyone who’s interested, here’s some history: We sell assorted antiques and collectibles on ebay and on TIAS. TIAS will let you upload auctions from their site, but the auction listing look pretty crummy. I use a listing app called eLister (mac-only) to develop listings that look much nicer. In order for TIAS to see listings on eBay, the images in your listing must be hosted on TIAS. To be hosted on TIAS, the images must be uploaded through a web browser, and their CGI app renames the images for you, in the “ItemNumber + AlphaCharacter” format.

So, with this script, I’m able to prename all the shots and get everything working nicely together! It takes about 40 seconds to run on my G3. If anybody wants to take a crack at speeding things up, please do. But right now it works like a champ. Thanks for all the postings and snippets of code. Mac people are so cool.