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?
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:
I found the reason my script receaved short filenames, i had done a registry patch to enable the drag and drop on ruby scripts and schortcuts as follows
But it had to be the following for LONG filenames
http://www.varioustopics.com/ruby/518646-rre-ruby-cygwin-and-paths.html
I learned a lot trying to figure this out!
However, @peter beat me to it with a much simpler solution.
Here is mine, in case someone finds it useful. file_get_long_name.rb
I got the idea from: an archived vb-world.net article and converted it to ruby.