AutoHotkey Community

It is currently May 27th, 2012, 11:05 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: April 16th, 2007, 3:47 pm 
Offline

Joined: April 16th, 2007, 3:35 pm
Posts: 3
Here is a script that creates a Media Player Classic playlist for all the videos in a particular directory. I know it is pretty rough and has many extra lines, but it seems to work fine.

Probably should have an array with the file types in it, and then loop over the array, but I don't know exactly how to do that yet.

BTW, the blank lines in the FileAppend command are crucial.


Code:
`::  ; writes a Media Player Classic Playlist file for all video files in chosen directory.  Accent key launches the script.

SetBatchLines, -1  ; Make the operation run at maximum speed.

;FileSelectFolder, WhichFolder,::{20d04fe0-3aea-1069-a2d8-08002b30309d}  ; Ask the user to pick a folder, My Computer option

FileSelectFolder, WhichFolder,%A_MyDocuments%  ; Ask the user to pick a folder, My Documents option

if (StrLen(WhichFolder) = 0)
   return ; No folder picked, so stop

SetWorkingDir, %WhichFolder%

FileAppend,
(
MPCPLAYLIST ; next blank line is crucial, don't delete

), play.mpcpl ; this is the name of the playlist file

count=1

If ErrorLevel <> 1
{
Loop, %WhichFolder%\*.mov, , 1 ; Quicktime
{

FileAppend,
(
%count%,type,0
%count%,filename,%A_LoopFileFullPath%

), play.mpcpl

count := count + 1   

}

}
Else
Exit

If ErrorLevel <> 1
{
Loop, %WhichFolder%\*.mpg, , 1 ; MPG
{

FileAppend,
(
%count%,type,0
%count%,filename,%A_LoopFileFullPath%

), play.mpcpl

count := count + 1   

}

}
Else
Exit

If ErrorLevel <> 1
{
Loop, %WhichFolder%\*.avi, , 1 ; AVI
{

FileAppend,
(
%count%,type,0
%count%,filename,%A_LoopFileFullPath%

), play.mpcpl

count := count + 1   

}

}
Else
Exit

If ErrorLevel <> 1
{
Loop, %WhichFolder%\*.wmv, , 1 ; Windows Media
{

FileAppend,
(
%count%,type,0
%count%,filename,%A_LoopFileFullPath%

), play.mpcpl

count := count + 1   

}

}
Else
Exit

If ErrorLevel <> 1
{
Loop, %WhichFolder%\*.mpeg, , 1 ; MPEG
{

FileAppend,
(
%count%,type,0
%count%,filename,%A_LoopFileFullPath%

), play.mpcpl

count := count + 1   

}

}
Else
Exit

return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 19th, 2007, 7:51 pm 
Offline

Joined: February 24th, 2007, 6:02 pm
Posts: 175
Location: Budapest, Hungary
The idea is very good, but be careful with the blocks.
Use indentation to make your script more readable if you post here on the Scripts & Functions topic.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 19th, 2007, 8:21 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
I recall someone once made a script to tidy up ahk code. Probably Rajat, but I could be remembering wrong.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2007, 6:50 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
engunneer wrote:
I recall someone once made a script to tidy up ahk code. Probably Rajat, but I could be remembering wrong.

I worked on it very long ago and its development wasn't continuous... toralf has done it very nicely here

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2008, 11:06 am 
Offline

Joined: July 21st, 2006, 12:26 am
Posts: 223
very nice, thanks for sharing

dont forget to include mkv ;D


Report this post
Top
 Profile  
Reply with quote  
 Post subject: mpc playlist software
PostPosted: April 15th, 2008, 10:19 pm 
Hi, I made a windows app for this, you can just drag a folder to the exe or use SendTo with right-click on it:

http://techsuki.net/mpc-tokyo-playlist/


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 15th, 2008, 10:20 pm 
ahh sorry forgot to add, works for these extensions:

.avi
.mpg
.mp4
.rmbv
.mkv
.mov
.ogm
.divx
.vob
.wmv


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 12:54 am 
Script wouldn't run for me. I don't really know what to do. I put it in C:\ with a .vbs extension and tried to run it from Start/Run.

The system tried but said there was an invalid character in Line 2, Char 1.

I've got WinXP SP2.

regards,

ab :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 6:02 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
since it is not a .vbs script, I can't see how it could work that way. Have you installed the program Autohotkey?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 7:10 am 
Offline

Joined: June 3rd, 2008, 12:57 am
Posts: 2
Well that explains a lot. Excuse my ignorance. It all falls into place. That's why the forum's called 'Autohotkey', yes? And it is a script for that piece of software.

I better go look for it.

........... short break.....................

Got it. Installed it. Renamed the script so's it ended in .ahk

Clicked on the script. Now I've got an icon "H" at the bottom of the screen.

Clicking on it brings up a screen that seems to be all about Autohotkey - I can get the User Manual from it, for instance - but no talk of a playlist for mpc anywhere.

I also tried that Tokyo thing and it appears as a choice for 'send to' but after sending stuff there... nothing.

I'm lost agin.....

:)


regards,

ab :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 7:59 am 
the first line of the code
Code:
`::

indicates that the action will start when you press the "`"- key.
Yould change this to something else, if you want. Look at the Hotkey-Section in the help.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 12:02 pm 
Offline

Joined: June 3rd, 2008, 12:57 am
Posts: 2
Yes, indeed. I finally found the key in question. Top left of my keyboard. I was thinking it was that other one - next to the semicolon - and I tried it and a couple of other guesses and got nowhere...

I should be okay now. Very interesting thing this autohotkey. If I can get the time from the family duties I'll look into it.

Thanks for your help.

regards,

ab :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2008, 7:29 pm 
abrogard wrote:
I also tried that Tokyo thing and it appears as a choice for 'send to' but after sending stuff there... nothing.


The playlist file is inside the folder after you use the sendto.


Report this post
Top
  
Reply with quote  
PostPosted: May 17th, 2009, 9:59 am 
Offline

Joined: February 15th, 2008, 2:14 pm
Posts: 1
Location: Germany
Hi EdwardATeller

i tried to enhance your script (it will create a playlist for every sub-dir below the chosen one), maybe is useful for you too.

Code:
;
; MPC Playlist Generator Original by EdwardATeller (see http://www.autohotkey.com/forum/topic18393.html)
; enhanced by zx48 5/09
;
; v0.01 Original Version by EdwardATeller
; v0.02 added Sub-dir Routine
; v0.03 added more file extensions
;
prog_name = MPC Playlist Generator v0.03  ; name and version of the program
#NoEnv                    ; be compatible to new AHK versions in 2007 :)
#SingleInstance, force    ; only one program instance allowed
SetBatchLines, -1         ; Make the operation run at maximum speed.

IfExist, Blinky.ico
  Menu, Tray, Icon, Blinky.ico                    ; if exist, show my favorite Simpson icon (try google 4 it :)
Menu, Tray, Tip, %prog_name% (be patient :)       ; show program info
ini_name = MPC_Playlist_creator.ini               ; settings file name
iniread, SourcePath, %ini_name%, settings, SourcePath, .\    ; save last dir for next use

LOG_File = %A_ScriptDir%\MPC_Playlist_Creator_log.txt
LogShow = 0                                       ; if true -> show logfile on exit
LogLevel = 2                                      ; 0 -> 3 log more information (higher value, more information)
PlayList = playlist.mpcpl                         ; playlist filename

if LogLevel > 1
  {
  text = Program Started
  Log2File(text)      ; log text message 2 file
  }
fileselectfolder,SRCRootFolder,*%SourcePath%,1, ; choose main directory
if ErrorLevel  ; exit on empty source
  {
  if LogLevel > 0
    {
    text = ERROR: program closed "source dir selection aborted"
    Log2File(text)      ; log text message 2 file
    }
  goto end
  }
iniwrite, %SRCRootFolder%, %ini_name%, settings, SourcePath    ; save path selection 4 next use
Loop, %SRCRootFolder%\*.*, 2, 1  ; only Folders but recursive
 DirList = %DirList%%A_LoopFileFullPath%`n
 Sort, DirList, C  ; sort Case sensitive
Loop, Parse, DirList,`n
{
if A_Loopfield =    ; exit if empty dir :)
  break
FileList =                      ; reset var for next iteration
SetWorkingDir, %A_Loopfield%    ; set actual dir for playlist generation
ifNotExist, %PlayList%          ; create playlist only if doesn't exist
 {
 Loop, %A_Loopfield%\*.avi, 0, 0  ; retrieve all AVI Files in current dir
   FileList = %FileList%%A_LoopFileName%`n
 Loop, %A_Loopfield%\*.wmv, 0, 0  ; retrieve all WMV Files in current dir
   FileList = %FileList%%A_LoopFileName%`n
 Loop, %A_Loopfield%\*.mpg, 0, 0  ; retrieve all Mpeg Files in current dir
   FileList = %FileList%%A_LoopFileName%`n
 Loop, %A_Loopfield%\*.mpeg, 0, 0  ; retrieve all MPEG Files in current dir
   FileList = %FileList%%A_LoopFileName%`n
 Loop, %A_Loopfield%\*.mov, 0, 0  ; retrieve all Quicktime Files in current dir
   FileList = %FileList%%A_LoopFileName%`n
 Sort, FileList, C  ; sort Case sensitive
  FileAppend, MPCPLAYLIST`n, %PlayList%    ; this is the header of the playlist file
  FileCounter = 1
  LoopCounter = 1
  Loop, parse, FileList,`n
  {
  if A_Loopfield =    ; exit if no file found
     break
  FileAppend,
(
%FileCounter%,type,0
%FileCounter%,filename,%A_LoopField%

), %PlayList%
  FileCounter += 1
  LoopCounter += 1
  }
  if LogLevel > 2
    {
    text = Playlist for directory %A_Loopfield% created
    Log2File(text)      ; log text message 2 file
    }
  if LoopCounter <= 2    ; remove single file playlist's
    {
    if LogLevel > 1
       {
       text = single File Playlist for directory %A_Loopfield% erased
       Log2File(text)      ; log text message 2 file
       }
     FileDelete, %PlayList%
    }
 }
}

End:
if LogLevel > 1
  {
  text = Program ended
  Log2File(text)      ; log text message 2 file
  }
if LogShow
  run, notepad.exe %Log_File%  ; show log
ExitApp,

return

Log2File(TextToLog)  ; Function Log Text 2 File
{
   global Log_File  ; This global variable was previously given a value somewhere outside this function.
   FileAppend, %A_DD%.%A_MM%.%A_YYYY% %A_HOUR%:%A_MIN%:%A_SEC% -> %TextToLog% `n, %Log_File%
}


regards zx48


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: rrhuffy and 5 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group