Copy Full Name, Directory or File Name to Clipboard

This forum allows you to share scripts with other Zeus users. Please do not post bug reports, feature requests or questions to this forum, but rather use it exclusively for posting scripts or for the discussion of scripts that have been posted.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Copy Full Name, Directory or File Name to Clipboard

Post by jussij »

Here are three macros that copy parts of the active document to the clipboard.

Code: Select all

--
--        Name: Copy Fully Qualified Filename to Clipboard
--
--      Author: Jussi Jumppanen
--
--    Language: Lua Macro
--
-- Description: This Lua macro copies the fully qualified name 
--              of the active document to the windows clipboard.
--

function key_macro()
  -- macro only works for documents
  local document = is_document()

  if document > 0 then
    local file_name = macro_tag("$fn")
    set_clipboard_text(file_name)
    message("'" .. file_name .. "' text added to clipboard.")
  else
    message("This macro only works for document files!")
    beep()
  end
end

key_macro() -- run the macro

Code: Select all

--
--        Name: Copy File Drive and Directory to Clipboard
--
--      Author: Jussi Jumppanen
--
--    Language: Lua Macro
--
-- Description: This Lua macro copies the drive and directory 
--              of the active document to the windows
--              clipboard.
--

function key_macro()
  -- macro only works for documents
  local document = is_document()

  if document > 0 then
    local file_name = macro_tag("$fdd")
    set_clipboard_text(file_name)
    message("'" .. file_name .. "' text added to clipboard.")
  else
    message("This macro only works for document files!")
    beep()
  end
end

key_macro() -- run the macro

Code: Select all

--
--        Name: Copy File Name to Clipboard
--
--      Author: Jussi Jumppanen
--
--    Language: Lua Macro
--
-- Description: This Lua macro copies the file name of the 
--              active document to the windows clipboard.
--

function key_macro()
  -- macro only works for documents
  local document = is_document()

  if document > 0 then
    local file_name = macro_tag("$f")
    set_clipboard_text(file_name)
    message("'" .. file_name .. "' text added to clipboard.")
  else
    message("This macro only works for document files!")
    beep()
  end
end

key_macro() -- run the macro
Post Reply