Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6811407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:19:24+00:00 2026-05-26T20:19:24+00:00

I want to make a tool that takes some filenames as parameters, but when

  • 0

I want to make a tool that takes some filenames as parameters, but when I use this code:

ARGV.each do|a|
  puts "Argument: #{a}"
end

and I use drag and drop or “send to” in Windows, I get the short filename.
So a file like "C:\Ruby193\bin\test\New Text Document.txt" becomes
C:\Ruby193\bin\test\NEWTEX~1.TXT as the argument.

There is no problem when I run the script from the commandline, with the longfilenames as parameters.

How do i get the long filename when i use drag and drop or send to?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:19:25+00:00Added an answer on May 26, 2026 at 8:19 pm

    I don’t know if it is possible to change the argument you recieve on a drag and drop, but you could use the Win32 getLongPathName() function, using the Ruby Win32 bindings

    –edit–
    Including @peter’s solution formatted for readability:

    require 'find'
    require 'fileutils'
    require 'Win32API'
    def get_long_win32_filename(short_name)
      max_path = 1024
      long_name = " " * max_path
      lfn_size = Win32API.new("kernel32", 
          "GetLongPathName", ['P','P','L'],'L').call(short_name, long_name, max_path)
      return (1..max_path).include?(lfn_size) ? long_name[0..lfn_size-1] : short_name
    end 
    
    ARGV.each do|a|
      puts a
      puts get_long_win32_filename(a)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a java-based GUI tool that checks for the latest version
I'm going to create some command line tools that make use of some large
I want to make a tool that can measure angles between two user defined
I want to make a Tool that enables the user to interact with Windows,
I want to make a tool that will make a video of your app
Let's say I want make some of my sources publicly available via my blog
We have a couple of very very slow JUnit tests that make heavy use
I'm a student and i want make a build tool as a side project
I'm building a little tool that lets user to place some geometric figures on
I want to make a script that will take a file, strip off the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.