Renaming file from contents of clipboard.

Hi,

I am starting to go mad and suspect what I want to do can’t be done in Automator especially with my limited skills.

I have an Excel workbook that has about 25 worksheets in it. The information in the workbook is changed most days and the last 10 worksheets are each moved out in to their own work book and these 10 workbooks are named and saved in a folder.

This is a time consuming task as the names for each worksheet are stored in cell B1 of each sheet so I have to copy the contents of B1, move a copy of the sheet to a new work book then save that work book to the relevant folder pasting the name in to the save as box.

I have an automator action now built that will extract the relevant sheet get the data from the cell, copy it to the clipboard and save the work book to the correct folder using a ‘standard name’.
Next it opens the ‘standard name’ file to rename it using finder actions but the problem is i cant work out how to get the name from the clipboard in to the save as box.

Is there a way to “paste” the clipboard contents straight in to the file name box or would I have to write a script to rename the file with the clipboard contents?

I’m struggling here as I am clueless with scripts so any help is very much appreciated an i suspect will be useful to a lot of people

Thanks in advance

Simon B

Model: Power Book G4
Browser: Safari 525.28.3
Operating System: Mac OS X (10.4)

Hi Simon,

neither Automator nor the Clipboard are needed for this task.
This AppleScript copies the specified sheets into single workbooks and saves each workbook
in the same folder as the source file with the appropriate names taken from cell B1.
You can adjust the properties. The negative values represent the range of the last ten elements (sheets).
You will be prompted to choose the source file

property sheetStart : -10
property sheetEnd : -1

set sourceFile to choose file
tell application "Finder" to set destinationFolder to container of sourceFile as text
tell application "Microsoft Excel"
	set sourceBook to open workbook workbook file name (sourceFile as text)
	set sourceSheets to worksheets of sourceBook
	repeat with i from sheetStart to sheetEnd
		set currentSheet to item i of sourceSheets
		set newFileName to value of range "B1:B1" of currentSheet
		copy worksheet currentSheet
		set destpath to (destinationFolder & newFileName & ".xls")
		save active workbook in destpath
		close active workbook
	end repeat
end tell

Stefan,

Wow thank you so much for your quick reply and solution. I will implement it this weekend (work has prevented me from doing it earlier) and will let you know how I get on.

Thank you

Simon

Hi Stefan,

It works perfectly thank you very much.

Simon

Hi,

I’ve been looking for a solution similar to the thread title, and this is the only place on the web I can find where the question’s been asked!

I’m currently archiving my DVD collection to an external hard drive so I can watch them at any time in Plex, and I’ve come up with an automator action to rip them with minimal interaction. You type the name of the film upon putting the DVD in the drive, and then later on, when the film has been ripped, you have to manually rename the file that has been created. Due to a piece of the workflow earlier on though, you only have to hit Paste, as the name you type in at the start of the process is copied to the clipboard.

However, I’d really like it if there was an action/script that automatically copied the contents of the clipboard into the filename. This way, I’d be able to put a DVD in and not worry about it until I see the notification telling me it’s done. Is this possible?

Edit: Never mind, I’ve figured it out :slight_smile:

tell application "Finder"
	set name of ("file pathf" as alias) to (the clipboard)
end tell

:slight_smile: