{"id":3947,"date":"2021-11-06T11:30:08","date_gmt":"2021-11-06T11:30:08","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=3947"},"modified":"2021-11-06T11:30:52","modified_gmt":"2021-11-06T11:30:52","slug":"improving-a-batch-script-to-play-random-videos-in-a-folder","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/improving-a-batch-script-to-play-random-videos-in-a-folder\/28798.html","title":{"rendered":"Improving A Batch Script To Play Random Videos In A Folder?"},"content":{"rendered":"<p>Hello, couple of months ago, a very helpful person by the name of Razor2.3 helped me with a batch that when executed, it will look into each folder of my shows, and from those shows randomly choose a video and then continue with the next folder and randomly pick a show and so forth.<\/p>\n<p>The batch would output an m3u playlist file and all I would have to do is to click the batch X amount of times and generates X amount of m3u playlists and all I would have to do is play that in my Windows media player without having to manually pick each episode for each show. (btw, I am using windows 7 PC).<\/p>\n<p>The final script was done and it looks like this:<\/p>\n<p>SET extensionList=avi mp4 mkv<br \/>\nSET cnt=0<br \/>\n:Loop<br \/>\nSET \/A cnt+=1<br \/>\nIF EXIST %cnt%.m3u GOTO Loop<\/p>\n<p>&gt;%cnt%.m3u ECHO.#EXTM3U<br \/>\nFOR \/D %%a IN (c:\\somePath\\*) DO CALL :PickFile &#8220;%%a&#8221;<br \/>\nGOTO :EOF<\/p>\n<p>:PickFile<br \/>\nSET searchList=<br \/>\nFOR %%b IN (%extensionList%) DO CALL SET searchList=%%searchList%% &#8220;%~1\\*.%%b&#8221;<br \/>\nFOR \/F %%b IN (&#8216;2^&gt;NUL DIR \/A-D-H-S %searchList% ^| FIND &#8220;File(s)&#8221;&#8216;) DO SET limit=%%b<br \/>\nSET \/A fileNum=(%random% %% limit) + 1<br \/>\nFOR \/F &#8220;tokens=2 delims=:&#8221; %%b IN (&#8216;2^&gt;NUL DIR \/A-D-H-S\/B %searchList% ^| FINDSTR \/N &#8220;.*&#8221; ^| FINDSTR &#8220;^%fileNum%:&#8221;&#8216;) DO ^<br \/>\nCALL :AddList %1 &#8220;%%b&#8221; &gt;&gt;%cnt%.m3u<br \/>\nGOTO :EOF<\/p>\n<p>:AddList<br \/>\n@ECHO.#EXTINF:-1,%~n2<br \/>\n@ECHO.%~f1\\%~2<br \/>\n@GOTO :EOF<\/p>\n<p>After weeks of testing, I found out that more often than not, it seems to repeat some episodes of my shows from my last playlist. (I would generate this playlist X amount of times)<\/p>\n<p>Is there a way to edit this so that I can make sure I don&#8217;t see a repeated episode from the last playlist? Or to make it even more random? I hope that makes sense, I can clarify even more on the next post. Thank you~<\/p>\n<p>BTW, the original post is here (https:\/\/computing.net\/answers\/programming\/is-there-a-way-to-play-a-random-video-just-once-in-a-folder\/28683.html#xtor=EPR-2)<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":4},"question-category":[55],"question_tags":[],"class_list":["post-3947","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/3947","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=3947"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=3947"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=3947"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=3947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}