Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator Rename File

I'm trying to see if there is a process to automate the following file renaming example:


I have example image file:


Smithson John.jpg


Automate process of making uppercase only the FIRST word the file name. Not the entire file name.


SMITHSON John.jpg



Posted on Feb 25, 2020 4:16 AM

Reply
4 replies

Feb 25, 2020 9:01 AM in response to Efthemi

Here are some clarification questions:

  1. Files are in a folder, and not in sub-folders of that folder? Yes, or no?
  2. Filenames are always Last First.ext? If not, what other format, and how should it be renamed.
  3. Are there formats where there are multiple spaces in the filename? Yes, or no?


I have an AppleScript that right now, renames as you originally requested. Want answeres to the preceding questions before I post it here.


Before:



After:


Feb 26, 2020 5:38 AM in response to VikingOSX

Got tired of waiting for an answer. The following AppleScript will prompt for a folder containing the files to rename. As written, it does not descend into sub-directories. Results shown in previous post.


Launch the Script Editor from Dock : Launchpad : Other. Copy/paste the following code into the Script Editor, click the compile (hammer) icon, and then click the Run button. You can save this script on your Desktop as .scpt, .scptd (script bundle), or .app — where it will run after a double-click on it.


use framework "Foundation"
use AppleScript version "2.4" -- requires Yosemite 10.10 or later
use scripting additions

property NSString : a reference to current application's NSString

set sfolder to (choose folder default location (path to desktop))

tell application "Finder"
	-- non-recursive, gets just files in the main folder location
	set fileLst to (every file of folder sfolder) as alias list
	
	if fileLst = {} then return
	
	repeat with afile in fileLst
		set afile's name to my upperCase(afile's name as text)
	end repeat
	set fileLst to {}
end tell
return

on upperCase(astr)
	-- split the passed name string into array elements, make the first element (last name) uppercase, and
	-- return reassembled filename string
	set mu_array to ((NSString's stringWithString:astr)'s componentsSeparatedByString:" ")'s mutableCopy()
	mu_array's replaceObjectAtIndex:0 withObject:((mu_array's firstObject())'s localizedUppercaseString())
	return (mu_array's componentsJoinedByString:" ") as text
end upperCase


Automator Rename File

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.