One Hotkey for 2 commands

I use MP3 Stag Studio from D.O. (selection of one mp3 file, launch by hotkey)

"%ProgramFiles%\Mp3-Tag Studio\mp3tag_s.exe" "-sxf{filepath}"

My problem is that that software use a different command line paramater (-sxd) when target is a directory

I can make 2 hotkeys but it's a bad way

How make a conditionnal launch in D.O. script ?

Another Question = How i can read mp3 artist field of selected mp3 file in a D.O. variable ?

i want create a folder with this value and not with the name of the file

[quote="jmb"]My problem is that that software use a different command line paramater (-sxd) when target is a directory

I can make 2 hotkeys but it's a bad way

How make a conditionnal launch in D.O. script ?[/quote]
I've just sent GPSoft a feature request suggesting a way to make it easier to do this. For now, though, you can use a bit of VBScript glue to make it happen.

You should just need to change your hotkey so that it calls Launch_MTS.vbs instead of mp3tag_s.exe (and also just pass it {filepath} on its own, without the -sxf or -sxd stuff, of course).

Here's what's in Launch_MTS.vbs, but it's also attached below for your convenience.

[code]option explicit

Dim args
set args = WScript.Arguments

if args.Count <> 1 then
MsgBox "Launch_MTS.vbs: No argument given."
WScript.Quit 1
end if

Dim filepath
filepath = args.Item(0)

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

Dim command

If fs.FileExists(filepath) Then
command = """%ProgramFiles%\Mp3-Tag Studio\mp3tag_s.exe"" ""-sxf" & filepath & """"
ElseIf fs.FolderExists(filepath) Then
command = """%ProgramFiles%\Mp3-Tag Studio\mp3tag_s.exe"" ""-sxd" & filepath & """"
Else
MsgBox "Launch_MTS.vbs: File or folder does not exist: """ & filepath & """"
WScript.Quit 1
End If

Dim shell
Set shell = CreateObject("WScript.Shell")

shell.Run(command)[/code]
Launch_MTS.zip (468 Bytes)

[quote="jmb"]Another Question = How i can read mp3 artist field of selected mp3 file in a D.O. variable ?

i want create a folder with this value and not with the name of the file[/quote]
Please, in future, ask separate questions in new threads. It makes the forum easier to search when other people are looking for answers to the same question.

If you need the artist name in order to organise the music files then the answer is in this FAQ:

HOW TO: Rename or move music files based on MP3 tags

You could try with the context menu option.
If the the program adds context menu for files and folders it's easy
If not you have to add it manually in "File Types".

[quote="nudel"][quote="jmb"]My problem is that that software use a different command line paramater (-sxd) when target is a directory

I can make 2 hotkeys but it's a bad way

How make a conditionnal launch in D.O. script ?[/quote]
I've just sent GPSoft a feature request suggesting a way to make it easier to do this. For now, though, you can use a bit of VBScript glue to make it happen.

You should just need to change your hotkey so that it calls Launch_MTS.vbs instead of mp3tag_s.exe (and also just pass it {filepath} on its own, without the -sxf or -sxd stuff, of course).

Here's what's in Launch_MTS.vbs, but it's also attached below for your convenience.

[code]option explicit

Dim args
set args = WScript.Arguments

if args.Count <> 1 then
MsgBox "Launch_MTS.vbs: No argument given."
WScript.Quit 1
end if

Dim filepath
filepath = args.Item(0)

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

Dim command

If fs.FileExists(filepath) Then
command = """%ProgramFiles%\Mp3-Tag Studio\mp3tag_s.exe"" ""-sxf" & filepath & """"
ElseIf fs.FolderExists(filepath) Then
command = """%ProgramFiles%\Mp3-Tag Studio\mp3tag_s.exe"" ""-sxd" & filepath & """"
Else
MsgBox "Launch_MTS.vbs: File or folder does not exist: """ & filepath & """"
WScript.Quit 1
End If

Dim shell
Set shell = CreateObject("WScript.Shell")

shell.Run(command)[/code][/quote]

thanks, i have think to make the same with 4NT

For anyone subscribed to this thead, there is another way of doing this, which doesn't require VBSCript, as explained in this thread:

[Help with copy command, distguish between file and directory)

See the second part of my reply. (The first part just explains the VBScript method from here.)