| View previous topic :: View next topic |
| Author |
Message |
akadewboy
Joined: 18 Aug 2006 Posts: 12
|
Posted: Fri Sep 15, 2006 4:55 am Post subject: How do I detect the filename? |
|
|
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 |
|
 |
bLisTeRinG
Joined: 15 Nov 2004 Posts: 45 Location: Warrnambool
|
Posted: Fri Sep 15, 2006 6:44 am Post subject: |
|
|
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 |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Fri Sep 15, 2006 8:16 am Post subject: |
|
|
| 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 |
|
 |
akadewboy
Joined: 18 Aug 2006 Posts: 12
|
Posted: Fri Oct 06, 2006 2:05 am Post subject: |
|
|
I beleive I've figured it out (thanks to a piece of code from your Mass Rename script PhiLho )
| 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 |
|
 |
|