AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I detect the filename?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
akadewboy



Joined: 18 Aug 2006
Posts: 12

PostPosted: Fri Sep 15, 2006 4:55 am    Post subject: How do I detect the filename? Reply with quote

What I'm trying to do is make a script that will convert an image into a jpg quickly from the "Open With" menu when you right click:



So far I've come up with this (JPGconvert.exe is in the same directory as IrfanView):

Code:
run i_view32.exe test.bmp /jpgq=80 /convert=new.jpg


Now obvously this only works if the image is named "test.bmp". How do I make it so it will convert the image no matter what it's filename is?
Back to top
View user's profile Send private message
bLisTeRinG



Joined: 15 Nov 2004
Posts: 45
Location: Warrnambool

PostPosted: Fri Sep 15, 2006 6:44 am    Post subject: Reply with quote

I've got this shortcut in my sendto folder:
Code:
"C:\Program Files\Tools\iView\i_view32.exe"


I think windows just pastes the filename on the end.

You could try %1% instead of the explicit filename.

Code:
run i_view32.exe %1% /jpgq=80 /convert=new.jpg


But. You'll have to do some string-splitting on the path\filename.extension so you can generate a new filename. Or, you could send the new file to a specific folder with the existing filename.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Fri Sep 15, 2006 8:16 am    Post subject: Reply with quote

bLisTeRinG wrote:
I've got this shortcut in my sendto folder:
Code:
"C:\Program Files\Tools\iView\i_view32.exe"


I think windows just pastes the filename on the end.
That's true, but SendTo is different of Open With... You also have to know that (last time I tried) you will receive the short path (8.3). That's probably to provide a compact string, no need for quotes. With AHK, it is easy to get the long path anyway.

akadewboy, you can also create in the registry a specific context menu entry, you would even not need an AHK script.
Something like (untested):
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\bmpfile\shell\convert]
@="Convert to Jpeg"

[HKEY_CLASSES_ROOT\bmp\shell\convert\command]
@="\"C:\\Program Files\\IrfanView\\i_view32.exe \"%1\" /jpgq=80 /convert=new.jpg"
Problem: it always output to the same name.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
akadewboy



Joined: 18 Aug 2006
Posts: 12

PostPosted: Fri Oct 06, 2006 2:05 am    Post subject: Reply with quote

I beleive I've figured it out (thanks to a piece of code from your Mass Rename script PhiLho Very Happy )

Code:

explorerClass = CabinetWClass ; Change your explorer class if needed
ControlGetText currentPath, Edit1, ahk_class %explorerClass%
ControlGet selectedFiles, List, Selected Col1, SysListView321, ahk_class %explorerClass%
   Loop Parse, selectedFiles, `n  ; Rows are delimited by linefeeds (`n).
   {
      Loop %currentPath%\%A_LoopField%*
      {
         fullName := A_LoopFileName ; Get the full name
      }
     SplitPath fullName, , , ext, nameNoExt ; Cuts extension off filename
     run i_view32.exe %fullname% /jpgq=80 /convert=%nameNoExt%.jpg ; Irfanview converts all images
   }
Return


It even works on multiple selected images.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group