set this_folder to (choose folder with prompt "Pick the folder containing the files to process:") as string
tell application "System Events"
set these_files to every file of folder this_folder
end tell
repeat with i from 1 to the count of these_files
set this_file to (item i of these_files as alias)
set this_info to info for this_file
if visible of this_info is true and alias of this_info is false then
-- insert actions here for: this_file
tell application "Finder"
get properties of this_file
set file_name to name of this_file
set file_name_extension to name extension of this_file
try
set file_comment to comment of this_file
if file_comment is not "" then
set name of this_file to file_comment & "." & file_name_extension
end if
on error errMsg number errNum
display dialog errMsg & " " & errNum giving up after 5
end try
end tell
end if
end repeat
on run {input, parameters}
(* Your script goes here *)
repeat with i from 1 to the count of input
set this_file to (item i of input as alias)
set this_info to info for this_file
if visible of this_info is true and alias of this_info is false then
-- insert actions here for: this_file
tell application "Finder"
get properties of this_file
set file_name to name of this_file
set file_name_extension to name extension of this_file
try
set file_comment to comment of this_file
if file_comment is not "" then
set name of this_file to file_comment & "." & file_name_extension
end if
on error errMsg number errNum
display dialog errMsg & " " & errNum giving up after 5
end try
end tell
end if
end repeat
-- return input
end run
on run {input, parameters}
(* Your script goes here *)
repeat with i from 1 to the count of input
set this_file to (item i of input as alias)
set this_info to info for this_file
if visible of this_info is true and alias of this_info is false then
-- insert actions here for: this_file
tell application "Finder"
get properties of this_file
set file_name to name of this_file
set file_name_extension to name extension of this_file
set file_length to (count of file_name) - (count of file_name_extension) - 1
set file_body to text 1 thru file_length of file_name
try
set file_comment to comment of this_file
if file_comment is not "" then
set name of this_file to file_body & "_" & file_comment & "." & file_name_extension
end if
on error errMsg number errNum
display dialog errMsg & " " & errNum giving up after 5
end try
end tell
end if
end repeat
-- return input
end run