Я пытаюсь создать действие «Папка» в Automator на Mac, где, когда новый файл удаляется в мою указанную папку, открывается диалоговое окно с вопросом, в какой файл я вхожу - то, основываясь на этом выборе, автоматически переименует его в обратный диалог и, в идеале, переменную сегодняшней даты (оставляя одно и то же расширение).AppleScript: использование диалога Возврат к файлу переименования
Довольно новый для AppleScripts, но это то, что я до сих пор, который не дает мне никаких ошибок, но и ничего не делает:
on run
set theChoice to {"Option1", "Option2", "Option3", "Option4", "Other"}
set selected to {choose from list theChoice}
if selected is "Option1" then
tell application "Finder"
set currentFile to name of (selection as alias)
set currentName to name of currentFile
set name of currentFile to "Option1" & "." & name extension of currentFile
end tell
else if selected is "Option2" then
tell application "Finder"
set currentFile to name of (selection as alias)
set currentName to name of currentFile
set name of currentFile to "Option2" & "." & name extension of currentFile
end tell
else if selected is "Option3" then
tell application "Finder"
set currentFile to name of (selection as alias)
set currentName to name of currentFile
set name of currentFile to "Option3" & "." & name extension of currentFile
end tell
else if selected is "Option4" then
tell application "Finder"
set currentFile to name of (selection as alias)
set currentName to name of currentFile
set name of currentFile to "Option4" & "." & name extension of currentFile
end tell
else
tell application "Finder"
set currentFile to name of (selection as alias)
set currentName to name of currentFile
set name of currentFile to alias & "." & name extension of currentFile
end tell
end if
end run
После выясняя эту часть, что я также надеялся добавить текущую дату (например, «_20160510») в конце каждого имени файла, поэтому, если это возможно, это также будет здорово.
Вы только изменили название временной переменной 'currentFile'. Вероятно, вам нужно что-то вроде 'set name (selection as alias) to currentFile' в качестве последнего шага. –
@PaulR Спасибо - я пытался сказать 'приложения "Finder" \t \t \t набор CurrentFile на имя (выбор в качестве псевдонима) \t \t \t набор currentName на имя CurrentFile \t \t \t набор имя CurrentFile к "Option1" & "." И расширение имен CurrentFile \t \t \t набор имя (выбор в качестве псевдонима) для CurrentFile \t \t конец tell', но это, похоже, не делать ничего. – Ryan