{"id":275,"date":"2013-04-01T00:15:42","date_gmt":"2013-04-01T06:15:42","guid":{"rendered":"http:\/\/www.crccheck.com\/blog\/?p=275"},"modified":"2015-10-11T22:23:39","modified_gmt":"2015-10-12T04:23:39","slug":"media-roulette","status":"publish","type":"post","link":"https:\/\/www.crccheck.com\/blog\/media-roulette\/","title":{"rendered":"Media Roulette.bat"},"content":{"rendered":"<p>So this weekend, I decided to scratch my own itch and figure out a way to play a random media file. Let&#8217;s say you&#8217;ve got a lot of tv shows or movies and you don&#8217;t want to browse&#8230; you want to channel surf. This is how you can do it in Windows:<\/p>\n<pre><code>chcp 65001\nsetlocal EnableDelayedExpansion\nset count=0\nfor \/f \"delims=\" %%a in ('dir \/b \/s *.avi *.mkv *.mp4 *.mov *.wmv') do @(\n    set filename[!count!]=%%a\n    set \/a count = count + 1\n)\n\n:loop\n\nset \/a choose = (%random% * 32768 + %random%) %% count\nset chosen=!filename[%choose%]!\nstart \"Opening %chosen%\" \"%chosen%\"\npause\n\ngoto loop\n<\/code><\/pre>\n<p>Thanks to all the random stack overflow posts I had to go through. And metafilter for actually having <a href=\"http:\/\/ask.metafilter.com\/183538\/Seeking-Windows-Random-Image-Viewer-and-Random-File-Opener\">something useful<\/a>. This isn&#8217;t the cleanest code, but it mostly works for me right now. I still have unicode problems, even with <code>chcp 65001<\/code>. Maybe I can access files by their 8.3 filename.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So this weekend, I decided to scratch my own itch and figure out a way to play a random media file. Let&#8217;s say you&#8217;ve got a lot of tv shows or movies and you don&#8217;t want to browse&#8230; you want to channel surf. This is how you can do it in Windows: chcp 65001 setlocal&hellip;<\/p>\n <a href=\"https:\/\/www.crccheck.com\/blog\/media-roulette\/\" title=\"Media Roulette.bat\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">Media Roulette.bat<\/span><\/a>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[4],"tags":[52,53,17],"class_list":["entry","author-showmewhatyougot","post-275","post","type-post","status-publish","format-standard","category-technical","tag-bat","tag-scripting","tag-win"],"_links":{"self":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/comments?post=275"}],"version-history":[{"count":2,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/275\/revisions"}],"predecessor-version":[{"id":278,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/275\/revisions\/278"}],"wp:attachment":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/media?parent=275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/categories?post=275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/tags?post=275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}