Automator: "Ask for Text" pass to "Rename Finder Items" possible?
Lets say there is monthly recurring documents that I scan, rename, relocate and tag. I would like to use automator to make this easier. The idea is the following:
- Create a folder action that is attached to the location where I would like to store the document.
- Move the scanned file to folder to trigger the workflow.
- Get a prompt ("Ask for text") for the year and month the document is for. (e.g. 2018-10)
- Combine the result with a fixed text (e.g. Document_Subject_).
- Rename the Document accordingly. Here to "Document_Subject_2018-10.xxx"
- Add Custom Tags
As of now I do feel kind of stupid as I am not getting anywhere. All the examples I could find regarding "Rename Finder Item" did not help.
What did work for me is to drop a file into a folder with attached workflow and have it automatically renamed and tagged. However the name is set in the automator and the tag is one of the available standard color tags. Both things are not what I need and I have not been able to adapt them to my need.
Thanks for any help!
I have found a partial solution to my problem. The workflow is not a simple as desired but does everything but points 1, 2 and 6. above. Point 6 (Add custom tags) is the one I would really like to add.
Solution 1:
Heres a script to rename the file to the correct format. But you must move files out of the folder after being processed or it will prompt to change the file name again, as you will see with this script. Please edit your question to include where you would like to move it (or even a folder select). I will also add the tag part after.
Use the "Run AppleScript" action for this:
on run {someFiles, parameters}
set theMonth to (do shell script "date +%m")
set theYear to (do shell script "date +%Y")
tell application "Finder"
repeat with theFile in someFiles
display dialog "Enter Static Text for " & the name of theFile default answer ""
set theStatic to the text returned of the result
set theEXT to (name extension of theFile)
tell application "System Events" to set the name of file (POSIX path of theFile) to theStatic & "_" & theYear & "-" & theMonth & "." & theEXT
end repeat
end tell
return input
end run