renaming files

I have imported a large number of files that have the following 2 naming conventions:

yyyy-mm-dd - [description]

I would like to rename all of these files as follows:

yyyymmdd - [description]
yyyymmdd - hhmmss

I have tried creating some smart groups to find all of these files but could not make it work. I have also tried renaming selected files using the script ‘Rename Using RegEx’ and this did not work either.

Can anyone point me at a useful guide or give me some tips ?

many thanks

Sean Spicer

2018-05-05 - Some Text ----> 20180505 - Some Text
2018-05-05_09_00_00 ----> 20180505 - 090000

Yes :slight_smile:

Assuming the “descriptions” contain no hyphens or underscores, this bit of code does it.

tell application id "DNtp"
	repeat with thisRecord in (selection as list)
		tell thisRecord
			set name to (do shell script "echo " & name & " | sed -E 's/_/ /1;s/_//g;s/-//g;s/ +/ - /1'")
		end tell
	end repeat
end tell

Obviously test it first and I always suggest doing the operation on reasonably-sized batches.