[Solved] How to check if folder exists

If you have a question or need help, this is the place to be.
Post Reply
User avatar
Neytrino-OnLine
Experienced User
Posts: 99
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

[Solved] How to check if folder exists

Post by Neytrino-OnLine » Fri Sep 02, 2016 12:00 pm

Hi, I need to find what type of media is in the bd-drive (DVD or bluray/nothin) and generate event, I think one of simplest ways - to check existence of the VIDEO_TS folder oan it.
But how to make it?
Last edited by Neytrino-OnLine on Tue Sep 06, 2016 1:43 pm, edited 1 time in total.
Sin©erely yours, Neytrino.

User avatar
kgschlosser
Site Admin
Posts: 5146
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: How to check if folder exists

Post by kgschlosser » Tue Sep 06, 2016 5:37 am

create a macro with a python script as an action.

copy this code and paste it into the script.

then add the event that takes place when inserting a disc into the same macro.


this will test to see if it's a blu-ray movie, a dvd movie or a data disk


Code: Select all

import os

drive = eg.eventString.split('.')[-1]

path = drive + ':\\'
bdmv = list(item for item in os.listdir(path) if item == 'BDMV')
dvd = list(item for item in os.listdir(path) if item == 'VIDEO_TS')

if bdmv:
    prefix = 'Blu-Ray.Disc'
elif dvd:
    prefix = 'DVD-Video.Disc'
else:
    prefix = 'Data.Disc'

eg.TriggerEvent(prefix=prefix, suffix='Inserted')
If you like the work I have been doing then feel free to Image

User avatar
Neytrino-OnLine
Experienced User
Posts: 99
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: How to check if folder exists

Post by Neytrino-OnLine » Tue Sep 06, 2016 11:20 am

Hi kgschlosser, thanks for the response, I get an error:
Attachments
Script.png
Sin©erely yours, Neytrino.

User avatar
kgschlosser
Site Admin
Posts: 5146
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: How to check if folder exists

Post by kgschlosser » Tue Sep 06, 2016 1:23 pm

you have to remove the 4 spaces in front of each line. sometimes a copy and paste does that
If you like the work I have been doing then feel free to Image

User avatar
Neytrino-OnLine
Experienced User
Posts: 99
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: How to check if folder exists

Post by Neytrino-OnLine » Tue Sep 06, 2016 1:42 pm

Thanks again, now it works!
Sin©erely yours, Neytrino.

User avatar
kgschlosser
Site Admin
Posts: 5146
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: How to check if folder exists

Post by kgschlosser » Tue Sep 06, 2016 1:47 pm

i don't know of the exact file structure of a Blu-Ray disk. if you take a screen shot of the disk opened up in windows explorer there is a good change i can get the movie name and what have you from the disc.

you would need to expand all of the folders for me. and if you can do the same for a dvd. this is will also make sure there aren't any mistakes upon triggering an event for the disc.

this would be most helpful. i like this idea and would like to add the code to the core version of EG i am building. that way it will tell you what kind of disk has been inserted instead of an event for one being inserted. and i would like it to contain some information about the disc as well.

i have a drive in my computer but unfortunately i put to long a screw in the sides of the drive to hold it in and the tray doesn't slide out. and i don't really want to get into taking the computer apart at this time to swap the screws out for something i use maybe once every 2 years. LOL
If you like the work I have been doing then feel free to Image

User avatar
Neytrino-OnLine
Experienced User
Posts: 99
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: [Solved] How to check if folder exists

Post by Neytrino-OnLine » Thu Sep 08, 2016 4:15 pm

kgschlosser, This is for You
"Remux" is files and folders only necessary for BD-Video structure (created by a tsMuxer), DVD & Blu-ray - screenshots of The Dictator extended cut edition...

I have one more idea (if it is interesting to you):
Lets will call it "wait for an event"
This action has 2 parameters:
1 - time
2 - name of an event
And should work like this:
when you execute it - it stops performance of the subsequent events (continuing to collect them) for a while time specified in parameters or before the event specified in parameters...
It can be useful in scenarios with inclusion or connection of additional devices...
It something like "Wait some time", but it can stop to wait not only when time is comes, but also earlier - if there comes the specefied event...
Sin©erely yours, Neytrino.

User avatar
kgschlosser
Site Admin
Posts: 5146
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: [Solved] How to check if folder exists

Post by kgschlosser » Thu Sep 08, 2016 9:08 pm

Neytrino-OnLine wrote:I have one more idea (if it is interesting to you):
Lets will call it "wait for an event"
This action has 2 parameters:
1 - time
2 - name of an event
And should work like this:
when you execute it - it stops performance of the subsequent events (continuing to collect them) for a while time specified in parameters or before the event specified in parameters...
It can be useful in scenarios with inclusion or connection of additional devices...
It something like "Wait some time", but it can stop to wait not only when time is comes, but also earlier - if there comes the specefied event...

this can already be done in EG, it has to be done using python script. but you would set a loop into motion that would keep on checking the event queue for the event you want. when doing this it blocks EG from firing any other events. and EG will queue anything that comes in. so you look through that queue in the loop if the event you want is there you move it to the front of the line. and exit the loop. then that one specified event is fired and after it has done with it what is needed. it will then trigger all the rest of the events in the queue.

give me a day and i will put together a script that does this for you

if you want
If you like the work I have been doing then feel free to Image

User avatar
Neytrino-OnLine
Experienced User
Posts: 99
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: [Solved] How to check if folder exists

Post by Neytrino-OnLine » Fri Sep 09, 2016 5:09 am

kgschlosser, If you could, it would be great!
Sin©erely yours, Neytrino.

User avatar
kgschlosser
Site Admin
Posts: 5146
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: [Solved] How to check if folder exists

Post by kgschlosser » Fri Sep 09, 2016 1:32 pm

i am goin to try and get some of it together for you today. but I have taken the back wall of my house off due to a water leak. and i am right in the middle of putting it all back together. and the guy that is helping me is leaving tomorrow morning. so i have to get like a weeks worth of work done in one day. it's a huge project i need to get my house at least dried in so no more water can get in. i was so exhausted last night i couldn't even think about coding something. we will see how things go today.

but hopefully this weekend if i manage to get done today what i need to. then i am going to rest for a week.
If you like the work I have been doing then feel free to Image

Post Reply