Jump to content

[VBScript]command line help


Recommended Posts

the code which i have right now is this.


Set fs = CreateObject("Scripting.FileSystemObject")
srcFolder = InputBox("Select the source folder.")

If NOT fs.FolderExists(srcFolder) Then
MsgBox("Error!, You need a path that exists!")
Else

Set fo = fs.GetFolder(srcFolder)
Set WshShell= CreateObject("WScript.Shell")
mp3packer = WshShell.ExpandEnvironmentStrings("mp3packer")

For Each x in fo.files
WshShell.Run(mp3packer & " " & "-z -t -s " & x)
Next
End If

the script runs without any errors. although when it runs mp3packer, it shows some kind of failiure on the consoles that keep popping up. the end result of the command line that the script does should be something like

mp3packer -z -t -s "C:\test\test.mp3"

comments would be most appreciated :)

Link to comment
Share on other sites


Are you sure this is a ExpandEnvironmentStrings.

mp3packer = WshShell.ExpandEnvironmentStrings("mp3packer")

Maybe try some thing like this, as it now will have the path to the exe.

mp3packer = WshShell.ExpandEnvironmentStrings("%ProgramFiles%\SomeFolder\The.exe")

Try this code instead

Dim Fso	   :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim ObjFolder : ObjFolder = InputBox("Select the source folder.")
If Not Fso.FolderExists(ObjFolder) Then
MsgBox("Error!, You need a path that exists!")
Else
Dim Act, StrF, MP3, ObjF
Set fo = Fso.GetFolder(ObjFolder)
Set StrF = fo.Files
Set Act = CreateObject("WScript.Shell")
Set MP3 = Fso.GetFile(Act.ExpandEnvironmentStrings("PLACE_THE_PATH_TO_THE_APP_HERE"))
For Each ObjF in StrF
Act.Run(MP3.Path & " -z -t -s " & ObjF.Path),1,True
Next
End If

Edited by gunsmokingman
Link to comment
Share on other sites

i tried it but it didn't work. i tried it on a folder that had 1 mp3 and the console only flashed and disappeared.

I am not familiar with the app you are using but the script does work.

I have modified the script so it produces a text file of the folder you

input into the inputbox. I also added a filter to it, and it listed either

mp3 or wma files in the folder.

Saves as List_MP3_Wma.vbs

 Dim Fso	   :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim ObjFolder : ObjFolder = InputBox("Select the source folder.")
If Not Fso.FolderExists(ObjFolder) Then
MsgBox("Error!, You need a path that exists!")
Else
Dim Act, StrF, MP3, ObjF, Rpt, Ts
Set fo = Fso.GetFolder(ObjFolder)
Set StrF = fo.Files
Set Act = CreateObject("WScript.Shell")
Rpt = Act.ExpandEnvironmentStrings("%UserProfile%\Desktop\Report.txt")
Set Ts = Fso.CreateTextFile(Rpt)
Ts.WriteLine Space(3) & Now() & vbCrLf &_
Space(2) & Chr(160) & fo.Path & vbCrLf &_
Chr(171) & " -------------------------- " & Chr(187)
'/-> Make Sure You Have The Full Path Here To The App You Are Using
' Set MP3 = Fso.GetFile(Act.ExpandEnvironmentStrings("PLACE_THE_PATH_TO_THE_APP_HERE"))
For Each ObjF in StrF
If InStr(ObjF.Path,"mp3") Or InStr(ObjF.Path,"wma") Then
'/-> Make Sure That The Swiches For The App Are Correct
' Act.Run(MP3.Path & " -z -t -s " & ObjF.Path),1,True
Ts.WriteLine Space(2) & Chr(160) & ObjF.Path & vbCrLf &_
Chr(171) & " -------------------------- " & Chr(187)
End If
Next
End If
Ts.Close()
Set StrF = Fso.GetFile(Rpt)
Act.Run("Notepad.exe " & StrF.Path),1,True
StrF.Delete()

This is what I got when I ran the script without the app

4/1/2007 7:39:47 AM

 F:\BetaHomesMusic

« -------------------------- »

 F:\BetaHomesMusic\Alive_And_Kicking.mp3

« -------------------------- »

 F:\BetaHomesMusic\All_Over_You.mp3

« -------------------------- »

 F:\BetaHomesMusic\All_Star.mp3

« -------------------------- »

 F:\BetaHomesMusic\All_These_Things_That_I've_Done.mp3

« -------------------------- »

 F:\BetaHomesMusic\All_The_Small_Things.mp3

« -------------------------- »

 F:\BetaHomesMusic\All_The_Things_She_Said.mp3

« -------------------------- »

 F:\BetaHomesMusic\Alone.mp3

« -------------------------- »

 F:\BetaHomesMusic\American_Idiot.mp3

« -------------------------- »

 F:\BetaHomesMusic\Aneurysm.mp3

« -------------------------- »

 F:\BetaHomesMusic\Another_Chance.mp3

« -------------------------- »

 F:\BetaHomesMusic\Aqua_Lung.mp3

« -------------------------- »

 F:\BetaHomesMusic\Aria.mp3

« -------------------------- »

 F:\BetaHomesMusic\Armageddon.mp3

« -------------------------- »

 F:\BetaHomesMusic\Asylum.mp3

« -------------------------- »

 F:\BetaHomesMusic\Ava_Adore.mp3

« -------------------------- »

 F:\BetaHomesMusic\Baby_Hold_On.mp3

« -------------------------- »

 F:\BetaHomesMusic\Bawitdaba.mp3

« -------------------------- »

 F:\BetaHomesMusic\BeachBreeze.mp3

« -------------------------- »

 F:\BetaHomesMusic\Bittersweet_Symphony.mp3

« -------------------------- »

 F:\BetaHomesMusic\Blinded_By_The_Light.mp3

« -------------------------- »

 F:\BetaHomesMusic\Bohemian_Rhapsody.mp3

« -------------------------- »

 F:\BetaHomesMusic\Born_Slippy.mp3

« -------------------------- »

 F:\BetaHomesMusic\Breaking_The_Law.mp3

« -------------------------- »

 F:\BetaHomesMusic\Candy_Oh.mp3

« -------------------------- »

 F:\BetaHomesMusic\Can_You_Feel.mp3

« -------------------------- »

 F:\BetaHomesMusic\Castles_In_The_Sky.mp3

« -------------------------- »

 F:\BetaHomesMusic\Children_Dream.mp3

« -------------------------- »

 F:\BetaHomesMusic\Children_Of_The_Sun.mp3

« -------------------------- »

 F:\BetaHomesMusic\China_Girl.mp3

« -------------------------- »

 F:\BetaHomesMusic\Clocks.mp3

« -------------------------- »

 F:\BetaHomesMusic\Coax_Me.mp3

« -------------------------- »

 F:\BetaHomesMusic\Cold_As_Ice.mp3

« -------------------------- »

 F:\BetaHomesMusic\Crazy_Train.mp3

« -------------------------- »

 F:\BetaHomesMusic\Criminal_Mind.mp3

« -------------------------- »

 F:\BetaHomesMusic\Cum_On_Feel_The_Noize.mp3

« -------------------------- »

 F:\BetaHomesMusic\D'yer_Mak'er.mp3

« -------------------------- »

 F:\BetaHomesMusic\Dancing_Queen.mp3

« -------------------------- »

 F:\BetaHomesMusic\Dancing_With_Tears_In_My_Eyes.mp3

« -------------------------- »

 F:\BetaHomesMusic\Deeper_And_Deeper.mp3

« -------------------------- »

 F:\BetaHomesMusic\Desenchantee.mp3

« -------------------------- »

 F:\BetaHomesMusic\Dirty_White_Boy.mp3

« -------------------------- »

 F:\BetaHomesMusic\Disco_Inferno.mp3

« -------------------------- »

 F:\BetaHomesMusic\DJ.mp3

« -------------------------- »

 F:\BetaHomesMusic\Dont_Need_A_Gun.mp3

« -------------------------- »

 F:\BetaHomesMusic\Dont_You_Forget_About_Me.mp3

« -------------------------- »

 F:\BetaHomesMusic\Dream_Police.mp3

« -------------------------- »

 F:\BetaHomesMusic\Driver_Seat.mp3

« -------------------------- »

 F:\BetaHomesMusic\Emotional_Rescue.mp3

« -------------------------- »

 F:\BetaHomesMusic\Enter_Sandman.mp3

« -------------------------- »

 F:\BetaHomesMusic\Everlong.mp3

« -------------------------- »

 F:\BetaHomesMusic\Everybody_Dance_Now.mp3

« -------------------------- »

 F:\BetaHomesMusic\Everybody_Wants_Some.mp3

« -------------------------- »

 F:\BetaHomesMusic\Everybody_Wants_You.mp3

« -------------------------- »

 F:\BetaHomesMusic\Eyes_Of_A_Stranger.mp3

« -------------------------- »

 F:\BetaHomesMusic\Eye_In_The_Sky.mp3

« -------------------------- »

 F:\BetaHomesMusic\Fat_Bottomed_Girls.mp3

« -------------------------- »

 F:\BetaHomesMusic\Feel_Alive.mp3

« -------------------------- »

 F:\BetaHomesMusic\Fernando.mp3

« -------------------------- »

 F:\BetaHomesMusic\Ferris_Bueller's_Day_Off_ Oh_Yeah.mp3

« -------------------------- »

 F:\BetaHomesMusic\Fire.mp3

« -------------------------- »

 F:\BetaHomesMusic\Five_Days_In_May.mp3

« -------------------------- »

 F:\BetaHomesMusic\Foolin.mp3

« -------------------------- »

 F:\BetaHomesMusic\Games_People_Play.mp3

« -------------------------- »

 F:\BetaHomesMusic\Get_Down_Tonight.mp3

« -------------------------- »

 F:\BetaHomesMusic\Get_Free.mp3

« -------------------------- »

 F:\BetaHomesMusic\Girls_And_Boys.mp3

« -------------------------- »

 F:\BetaHomesMusic\God_Save_The_Queen.mp3

« -------------------------- »

 F:\BetaHomesMusic\Gold_Dust_Woman.mp3

« -------------------------- »

 F:\BetaHomesMusic\Go_Your_Own_Way.mp3

« -------------------------- »

 F:\BetaHomesMusic\Groove_Is_In_The_Heart.mp3

« -------------------------- »

 F:\BetaHomesMusic\Ground_Control_To_Major_Tom.mp3

« -------------------------- »

 F:\BetaHomesMusic\Heartbreaker_Living_Loving_Maid.mp3

« -------------------------- »

 F:\BetaHomesMusic\Heart_Of_Glass.mp3

« -------------------------- »

 F:\BetaHomesMusic\Here_Comes_The_Sun.mp3

« -------------------------- »

 F:\BetaHomesMusic\Hold_Your_Hands_Up_High.mp3

« -------------------------- »

 F:\BetaHomesMusic\Hollywood_Nights.mp3

« -------------------------- »

 F:\BetaHomesMusic\Hungry_Like_The_Wolf.mp3

« -------------------------- »

 F:\BetaHomesMusic\I'll_Melt_With_You.mp3

« -------------------------- »

 F:\BetaHomesMusic\I'm_Afraid_Of_Americans.mp3

« -------------------------- »

 F:\BetaHomesMusic\I'm_Burning_For_You.mp3

« -------------------------- »

 F:\BetaHomesMusic\If_It_Feels_Good,_Do_It.mp3

« -------------------------- »

 F:\BetaHomesMusic\If_I_Were_You.mp3

« -------------------------- »

 F:\BetaHomesMusic\In_Bloom.mp3

« -------------------------- »

 F:\BetaHomesMusic\In_Your_Eyes.mp3

« -------------------------- »

 F:\BetaHomesMusic\Its_Raining_Men.mp3

« -------------------------- »

 F:\BetaHomesMusic\I_Hear_You_Calling.mp3

« -------------------------- »

 F:\BetaHomesMusic\I_Like_Love.mp3

« -------------------------- »

 F:\BetaHomesMusic\I_Ran.mp3

« -------------------------- »

 F:\BetaHomesMusic\I_Want_To_Be_Sedated.mp3

« -------------------------- »

 F:\BetaHomesMusic\I_Want_You.mp3

« -------------------------- »

 F:\BetaHomesMusic\I_Want_You_To_Want_Me.mp3

« -------------------------- »

 F:\BetaHomesMusic\I_Was_Made_For_Loving_You.mp3

« -------------------------- »

 F:\BetaHomesMusic\JailBreak.mp3

« -------------------------- »

 F:\BetaHomesMusic\Janeiro.mp3

« -------------------------- »

 F:\BetaHomesMusic\Jungle_Love.mp3

« -------------------------- »

 F:\BetaHomesMusic\Kick_Start_My_Heart.mp3

« -------------------------- »

 F:\BetaHomesMusic\Kids_In_America.mp3

« -------------------------- »

 F:\BetaHomesMusic\Knocking_At_Your_BackDoor.mp3

« -------------------------- »

 F:\BetaHomesMusic\Learning_To_Fly.mp3

« -------------------------- »

 F:\BetaHomesMusic\Learn_To_Fly.mp3

« -------------------------- »

 F:\BetaHomesMusic\Let's_Go.mp3

« -------------------------- »

 F:\BetaHomesMusic\Let_Love_Rule.mp3

« -------------------------- »

 F:\BetaHomesMusic\Let_The_Good_Times_Roll.mp3

« -------------------------- »

 F:\BetaHomesMusic\Lithium.mp3

« -------------------------- »

 F:\BetaHomesMusic\Living_After_Midnight.mp3

« -------------------------- »

 F:\BetaHomesMusic\Living_On_A_Prayer.mp3

« -------------------------- »

 F:\BetaHomesMusic\Loser.mp3

« -------------------------- »

 F:\BetaHomesMusic\Losing_California.mp3

« -------------------------- »

 F:\BetaHomesMusic\Love_Profusion.mp3

« -------------------------- »

 F:\BetaHomesMusic\Love_Removal_Machine.mp3

« -------------------------- »

 F:\BetaHomesMusic\Love_Song.mp3

« -------------------------- »

 F:\BetaHomesMusic\Low_Rider.mp3

« -------------------------- »

 F:\BetaHomesMusic\Lunatic_Fringe.mp3

« -------------------------- »

 F:\BetaHomesMusic\L_A_Woman.mp3

« -------------------------- »

 F:\BetaHomesMusic\Mad_About_You.mp3

« -------------------------- »

 F:\BetaHomesMusic\Make_Me_Dance_All_Night.mp3

« -------------------------- »

 F:\BetaHomesMusic\Making_Plans_For_Nigel.mp3

« -------------------------- »

 F:\BetaHomesMusic\Mary_Janes_Last_Dance.mp3

« -------------------------- »

 F:\BetaHomesMusic\Missing.mp3

« -------------------------- »

 F:\BetaHomesMusic\Miss_America.mp3

« -------------------------- »

 F:\BetaHomesMusic\Miss_Plaza_Suite.mp3

« -------------------------- »

 F:\BetaHomesMusic\More_Than_A_Feeling.mp3

« -------------------------- »

 F:\BetaHomesMusic\My_Woman_From_Tokyo.mp3

« -------------------------- »

 F:\BetaHomesMusic\NineTeen79.mp3

« -------------------------- »

 F:\BetaHomesMusic\Nirvana_I_Forgot_It_Name.mp3

« -------------------------- »

 F:\BetaHomesMusic\Not_In_Love.mp3

« -------------------------- »

 F:\BetaHomesMusic\No_Matter_What_You_Do.mp3

« -------------------------- »

 F:\BetaHomesMusic\One_Gun.mp3

« -------------------------- »

 F:\BetaHomesMusic\One_More_Time.mp3

« -------------------------- »

 F:\BetaHomesMusic\One_Tree_Hill.mp3

« -------------------------- »

 F:\BetaHomesMusic\Out_Tath_Away.mp3

« -------------------------- »

 F:\BetaHomesMusic\Paint_It_Black.mp3

« -------------------------- »

 F:\BetaHomesMusic\Paraniod.mp3

« -------------------------- »

 F:\BetaHomesMusic\Photograph.mp3

« -------------------------- »

 F:\BetaHomesMusic\Radio_Ga_Ga.mp3

« -------------------------- »

 F:\BetaHomesMusic\Red_Rover.mp3

« -------------------------- »

 F:\BetaHomesMusic\Relax.mp3

« -------------------------- »

 F:\BetaHomesMusic\Rock_SuperStar.mp3

« -------------------------- »

 F:\BetaHomesMusic\Running_Down_A_Dream.mp3

« -------------------------- »

 F:\BetaHomesMusic\School.mp3

« -------------------------- »

 F:\BetaHomesMusic\Shake_Your_Booty.mp3

« -------------------------- »

 F:\BetaHomesMusic\She_Sells_Sanctuary.mp3

« -------------------------- »

 F:\BetaHomesMusic\Shoot_To_Thrill.mp3

« -------------------------- »

 F:\BetaHomesMusic\Somebody_Told_Me.mp3

« -------------------------- »

 F:\BetaHomesMusic\Song_2.mp3

« -------------------------- »

 F:\BetaHomesMusic\So_Yesterday.mp3

« -------------------------- »

 F:\BetaHomesMusic\SpaceShip_SuperStar.mp3

« -------------------------- »

 F:\BetaHomesMusic\Starry_Eyed_Surprise.mp3

« -------------------------- »

 F:\BetaHomesMusic\Staying_Together_For_The_Kids.mp3

« -------------------------- »

 F:\BetaHomesMusic\Straight_Ahead.mp3

« -------------------------- »

 F:\BetaHomesMusic\Strange_Animal.mp3

« -------------------------- »

 F:\BetaHomesMusic\Street_Fighting_Man.mp3

« -------------------------- »

 F:\BetaHomesMusic\Sympathy_For_The_Devil.mp3

« -------------------------- »

 F:\BetaHomesMusic\Take_A_Chance_On_Me.mp3

« -------------------------- »

 F:\BetaHomesMusic\Take_It_Easy.mp3

« -------------------------- »

 F:\BetaHomesMusic\Take_Me_Away_Into_The_Night.mp3

« -------------------------- »

 F:\BetaHomesMusic\The_Boys_In_The_Bright_White_Sports_Car.mp3

« -------------------------- »

 F:\BetaHomesMusic\The_End_Is_The_Beginning_Is_The_End.mp3

« -------------------------- »

 F:\BetaHomesMusic\The_Fight_Song.mp3

« -------------------------- »

 F:\BetaHomesMusic\The_Hurting.mp3

« -------------------------- »

 F:\BetaHomesMusic\The_Rockafeller_Skank.mp3

« -------------------------- »

 F:\BetaHomesMusic\The_Silence.mp3

« -------------------------- »

 F:\BetaHomesMusic\The_Spirit_Of_The_Radio.mp3

« -------------------------- »

 F:\BetaHomesMusic\Tom_Sawyer.mp3

« -------------------------- »

 F:\BetaHomesMusic\Too_Much_Time_On_My_Hands.mp3

« -------------------------- »

 F:\BetaHomesMusic\Transmission.mp3

« -------------------------- »

 F:\BetaHomesMusic\Twilight_Zone.mp3

« -------------------------- »

 F:\BetaHomesMusic\Until_You_Love_Me.mp3

« -------------------------- »

 F:\BetaHomesMusic\Vacation.mp3

« -------------------------- »

 F:\BetaHomesMusic\Video_Killed_The_Radio_Star.mp3

« -------------------------- »

 F:\BetaHomesMusic\Violet.mp3

« -------------------------- »

 F:\BetaHomesMusic\We_Got_The_Beat.mp3

« -------------------------- »

 F:\BetaHomesMusic\Whiskey_In_The_Jar.mp3

« -------------------------- »

 F:\BetaHomesMusic\Wild_Wild_West.mp3

« -------------------------- »

 F:\BetaHomesMusic\Working_Man.mp3

« -------------------------- »

 F:\BetaHomesMusic\World_On_Fire.mp3

« -------------------------- »

 F:\BetaHomesMusic\You_Could_Be_Mine.mp3

« -------------------------- »

 F:\BetaHomesMusic\You_Got_Another_Thing_Coming.mp3

« -------------------------- »

Link to comment
Share on other sites

Further information:

The basic program command line looks like this:

mp3packer -z -t -s input.mp3 [ output ]

Processes input.mp3 and saves the output to output. If output is a directory, mp3packer will keep the same name as input but in the output directory.

The program itself however is capable of performing the task you require of it without having to use a script to list all the mp3s first.
mp3packer -z -t -s inDir [ outDir ]

Processes all files ending in ".mp3" in the directory inDir. If outDir is given, all output files will have the same name in the outDir directory. If outDir is not given, the files will have the -a string appended to them, and will stay in inDir.

-t

Strip non-MP3 data at the beginning of the file. This will remove some kinds of ID3v2 tags. Use both -s and -t to remove all tags.

-s

Strip non-MP3 data at the end of the file. Using this option will remove most tags and any incomplete last frames from the file.

-z

This option makes mp3packer actually decode the audio, do a brute-force search for optimal encoding parameters, then re-encode it. It is quite a bit safer than the old -z switch, but it increases the time to repack the files dramatically. On my computer, a 4-minute file which would get repacked in the blink of an eye would take around 30 seconds with this option enabled.

-a "-vbr"

Specify the string to append to the file name if no output file name is given. If mp3packer -a "-food" input.mp3 is given, the output will be named input-food.mp3. "-vbr" is the default.

What this actually means is that you would be better off asking for user input for either
  • InDir and OutDir
  • InDir and -a

My guess, especially due to the time lapse caused by the -z switch is that using the script to individually process each mp3 is a bad idea when the program is already coded to process all mp3s in a directory.

Link to comment
Share on other sites

thanks for the explination. i had no idea that mp3packer could do that.

i recently made some changes to the script.

Set fs		=	CreateObject("Scripting.FileSystemObject")
srcFolder = InputBox("Select the source folder.")
If NOT fs.FolderExists(srcFolder) Then
MsgBox("Error!, You need a path that exists!")
Else
Set WshShell= CreateObject("WScript.Shell")
WshShell.Run("C:\WINDOWS\system32\stuff\mp3packer.exe" & " -z -t -s " & Chr(34) & srcFolder & Chr(34))
End If

it works :)

Edited by Mangix
Link to comment
Share on other sites

No problem!

It's actually one of the reasons why it seems we want to know too much. People can start with an idea and set off on a solution only to find that there are other, possibly better alternatives.

I see you went with the chr(34) idea too!, I didn't know if it was needed since many people use underscores as a replacement for spaces, but better safe than sorry

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...