Question

Is there Batch code/c# for if say for example, I have a anime folder and a movies folder and I want to watch anime with program A and movies with Program B.
Is there a way I can get the same file type (.mkv/.avi/.mp4) to open with different programs depending on its folder/hard drive location?
I assume I will have to set all video file types to open this batch but I do not know the arguments to enter.
Thanks.

Was it helpful?

Solution

You could write a batch file that launches the appropriate application based on the folder, like so:

IF /I "%~dp1"=="C:\anime\" programA.exe %*
IF /I "%~dp1"=="C:\movie\" programB.exe %*    

Then right-click on one of your files and choose Open With - Choose Default Program, then browse to the .bat file you just created. Make sure the checkbox "Always use the selected program to open this kind of file" is checked.

From now on, you can simply double-click the file and the correct program will be launched.

OTHER TIPS

If you have located your file, you can create a FileInfo object for it, and check it's Directory path by:

FileInfo file = new FileInfo(@"c:\Anime\Anime.avi"); 
string dirPath = file.DirectoryName;

if (dirPath == @"c:\Anime")
{
  //Open with VLC
}
else if (dirPath == ...something else...)
{
  //Open with something else
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top