senshi Posted May 29, 2005 Posted May 29, 2005 OK, I hope I can explain this well enough for some genius to understand and help me out Im going to make a batch file that will be loaded by right-clicking mp3 files and selecting "some option" from the context menu.Assuming I save this batch file as: C:\Windows\test.batNow, on right-clicking an mp3 file I will have an option that, if selected, will perform the following run command: "C:\Windows\test.bat" %1The %1 automatically sets the selected mp3s filepath as a variable called %1 in the batch file.So lets say I rightclick on C:\music\coolsong.mp3 and select "the option" from the menu... C:\Windows\test.bat will now load up and have the variable %1 which = "C:\music\coolsong.mp3"Now here is what I want to do with this %1 variable:I want to create a new variable with the selected mp3s directory path instead of the filepath. So for this example I will need to somehow set a variable which = "C:\music\"I really don't know what to do. All I want is to take the variable I already have ("C:\music\coolsong.mp3") and transform it to: "C:\music\"I really hope somebody here can help me out.If anything, maybe someone here knows of a forum that I can join which specializes in topics about creating batch files?? It would really help me out.Thanks alot everyone.
drBozo Posted May 29, 2005 Posted May 29, 2005 In your batch file, use this command:@for %%F in (%1) do set New_Var_1=%%~dpFThis will set variable New_Var_1 as drive letter and path of %1.For more information, check usenet newsgroup alt.msdos.batch, or the XP manual of the FOR command.
senshi Posted May 29, 2005 Author Posted May 29, 2005 Hey I managed to figure it out with the help of someone on another forum.Here is what needs to be done (for anyone interested):for %%i in (%1) do echo %%~dpiThe above code will take the variable that has the complete filepath and echo the directory path only
senshi Posted May 29, 2005 Author Posted May 29, 2005 Hey drBozo, you beat me to it by 1 min. And yes, setting the new var does exactly what I need. I appreciate the reply. Thanks for helping
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now