File Rename Complex w/delimiter, copy and paste

Hi all,

I am a newbie and have scanned the archives (though there are a lot of topics related to filenaming) and have not found what I’m looking for…

I have two questions:

Q1: Delimiter and swap

I have a lot of files in the following format
abc - def.ext

These files may have different lengths of parts, separated by the “-” e.g.,
aaaaabbbbcccc - ddddddefff.ext

“ext” is the extension and should remain the same.

and want to rename them as

def - abc.ext

In other words, I want to copy the text up to the “-”, then delete it from the file name, then append it at the end, separated by a “-”?

Q2: Two files 1 name
I have two files (a large quantity in this pairing) - they are linked. The EXT(2) is metadata for EXT(1).

abcdef.EXT(1)
abcdef.EXT(1).EXT(2)

What happens is I run abcdef.EXT(1) through a process which results in a prepend of the file name. eg, 123-abcdef.EXT(1)

Once this happens, they become unlinked and therefore requiring me to rename the EXT(2) in bulk…

Is there a way to copy “123-abcdef” into a cue and then paste this over the 2nd file, resulting in 123-abcdef.EXT(1).EXT(2)?

I’d love to do this via droplet - drop the first file, to copy the string and then drop the 2nd file for target renaming.

That’s it…
Any help would be greatly appreciated!

Moosh
:slight_smile:

Hi,

Q1:


on open theseItems
	set {TID, text item delimiters} to {text item delimiters, "-"}
	repeat with oneItem in theseItems
		set {name:Nm, name extension:Ex} to (info for oneItem)
		set baseName to text 1 thru ((get offset of "." & Ex in Nm) - 1) of Nm
		tell text items of baseName to set newName to item 2 & "-" & item 1 & "." & Ex
		tell application "Finder" to set name of contents of oneItem to newName
	end repeat
	set text item delimiters to TID
end open

save the script as application bundle and drop the files onto it

WOW.

that was amazing!

Thank you!!!