Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
Thread Tools | Search this Thread | Display Modes |
22nd February 2005, 05:38 | #21 | Link |
Registered User
Join Date: Oct 2001
Location: france
Posts: 521
|
here I go:
http://esby.free.Fr/prog/dnd dnd.exe is the windowed executable dndc.exe is the console one. you can modify extension options via dnd.ini file or via -xmp3 -Xm3u command line options (those are examples). command line option available: -h for help -xextension (mp3) -Xextension (m3u) -s (saving ini) -wmyfile.m3u (to write all items to myfile.m3u' Please note that this last mode cancels auto mode generation. (eg if you specify two paths, it will generate only ONE m3u file) Any other argument that does not start by - will be considered as a file or a path to add. For example: dndc c:\ will scan the drive c:\ for mp3 files and will create m3u files for each directory that contains mp3 files... esby
__________________
http://esby.free.fr/ Last edited by esby; 22nd February 2005 at 05:45. |
22nd February 2005, 07:36 | #22 | Link |
Registered User
Join Date: Jan 2004
Posts: 332
|
hi i took this as a challenge
so here it goes (i commented it so i wont explain a lot) just one thing ... you need to put your code to create m3u playlist... Code:
:: DIRMAGIC.BAT - parse current directory name without path :: :: # Since the "pure" DOS code is slower check Win version and use :: the FOR command with /F switch if supported (Win2k/XP) :: # also writes temp files to disk (it's not that slow) :: :: IF %OS%==Windows_NT Goto WinNT :: NOT SURE!!! :: @ECHO off ECHO. IF "%1"=="UseMethod2" GOTO Method2 IF "%2"=="Parsing" GOTO Parse :: :: :: :: # write temp files to TEMP directory :: :: :: :: IF "%TEMP%"=="" SET _ERROR=TEMP variable not set :: IF NOT EXIST "%TEMP%.\nul" SET _ERROR=TEMP directory not valid :: IF NOT "%_ERROR%"=="" GOTO Error :: :: %TEMP%\ :: CD %TEMP% :: :: :: NOT POSSIBLE??? :: :: (check PROMPT usage and tricks) :: :: # gat dir name method 1 (long name with spaces) :: not supported names with "," ";" "=" (MAYBE MORE!!!) > DIRECTORY.BAT ECHO SET _DIR=%%2 >> DIRECTORY.BAT ECHO SHIFT >> DIRECTORY.BAT ECHO :Loop >> DIRECTORY.BAT ECHO IF NOT "%%2"=="" FOR %%%%X IN ( SET SHIFT GOTO:Loop ) DO %%%%X _DIR=%%_DIR%% %%2 > CALLMAIN.BAT DIR %0 | FIND "Directory of " | FIND ":\" :: output: :: Directory of DIRECTORY_NAME :: DIRECTORY.BAT %1 %2 CALL CALLMAIN.BAT ECHO Directory: ECHO "%_DIR%" IF EXIST "%_DIR%.\nul" GOTO Substitute ECHO Not valid directory name GOTO SecondRun :SecondRun %0 UseMethod2 GOTO End :: TO BE SURE! :: :: # get dir name method 2 (short file name) :: using undocumented TRUENAME command :: :: $ TRUENAME /? :: Reserved command name :Method2 ECHO %1 > INVALID.BAT ECHO SET _DIR=%%4 > CALLMAIN.BAT MODE ThisIsTrick .\ >> CALLMAIN.BAT TRUENAME | FIND ":\" :: output: :: Invalid parameter - ThisIsTrick DIRECTORY_NAME :: INVALID.BAT %1 %2 %3 %4 CALL CALLMAIN.BAT DEL INVALID.BAT ECHO Directory: ECHO "%_DIR%" IF EXIST "%_DIR%.\nul" GOTO Substitute SET _ERROR=Valid directory name not found GOTO Error :: :: # use for easier dir name parsing :: :: $ SUBST /? :: Associates a path with a drive letter. :: SUBST [drive1: [drive2:]path] :: SUBST drive1: /D :: drive1: Specifies a virtual drive to which you want to :: assign a path :: [drive2:]path Specifies a physical drive and path you want to :: assign to a virtual drive. :: /D Deletes a substituted (virtual) drive. :: Type SUBST with no parameters to display a list of current :: virtual drives. :: :: # dropped (maybe if dir is valid input parameter) :Substitute GOTO ThirdRun :ThirdRun IF "%1"=="UseMethod2" %0 Method2 Parsing %_DIR% %0 Method1 Parsing %_DIR% GOTO End :: :: # parse dir name with CHOICE :: :Parse ECHO %1 %2... :: :: # parse dir test :: > PARSEDIR.BAT ECHO :Loop :: >> PARSEDIR.BAT ECHO IF NOT "%%1"=="" FOR %%%%X IN ( ECHO SHIFT GOTO:Loop ) DO %%%%X %%1 :: :: :: # parse dir test output (C:\My Documents): :: :: ?[ drop :: :: C drop :: :: : drop :: :: \ drop (first run "?[" drop first 4 char) :: :: M keep :: :: Y keep :: :: ]? drop (end) :: :: ??[ drop (second run "??[") :: :: D keep with space first :: :: O keep :: :: C keep :: :: U keep # PLUS: :: :: M keep # on every "\" char reset var :: :: E keep :: :: N keep :: :: T keep :: :: S keep :: :: ]? drop IF "%1"=="Method2" GOTO ParseDir2 :: # FINAL PARSE DIR METHOD 1 :: > PARSEDIR.BAT ECHO IF "%%1"=="?[" GOTO FirstRun >> PARSEDIR.BAT ECHO GOTO SecondRun >> PARSEDIR.BAT ECHO. >> PARSEDIR.BAT ECHO :FirstRun >> PARSEDIR.BAT ECHO IF "%%5"=="]?" GOTO End >> PARSEDIR.BAT ECHO SET _DIRMAGIC=%%5 >> PARSEDIR.BAT ECHO IF "%%5"=="\" SET _DIRMAGIC= >> PARSEDIR.BAT ECHO SHIFT >> PARSEDIR.BAT ECHO IF "%%5"=="]?" GOTO End >> PARSEDIR.BAT ECHO :FirstLoop >> PARSEDIR.BAT ECHO IF "%%5"=="\" SET _DIRMAGIC= >> PARSEDIR.BAT ECHO IF "%%5"=="\" SHIFT >> PARSEDIR.BAT ECHO IF "%%5"=="]?" GOTO End >> PARSEDIR.BAT ECHO IF NOT "%%5"=="]?" FOR %%%%X IN ( SET SHIFT GOTO:FirstLoop ) DO %%%%X _DIRMAGIC=%%_DIRMAGIC%%%%5 >> PARSEDIR.BAT ECHO GOTO End >> PARSEDIR.BAT ECHO. >> PARSEDIR.BAT ECHO :SecondRun >> PARSEDIR.BAT ECHO IF "%%2"=="]?" GOTO End >> PARSEDIR.BAT ECHO SET _DIRMAGIC=%%_DIRMAGIC%% %%2 >> PARSEDIR.BAT ECHO IF "%%2"=="\" SET _DIRMAGIC= >> PARSEDIR.BAT ECHO SHIFT >> PARSEDIR.BAT ECHO IF "%%2"=="]?" GOTO End >> PARSEDIR.BAT ECHO :SecondLoop >> PARSEDIR.BAT ECHO IF "%%2"=="\" SET _DIRMAGIC= >> PARSEDIR.BAT ECHO IF "%%2"=="\" SHIFT >> PARSEDIR.BAT ECHO IF "%%2"=="]?" GOTO End >> PARSEDIR.BAT ECHO IF NOT "%%2"=="]?" FOR %%%%X IN ( SET SHIFT GOTO:SecondLoop ) DO %%%%X _DIRMAGIC=%%_DIRMAGIC%%%%2 >> PARSEDIR.BAT ECHO GOTO End >> PARSEDIR.BAT ECHO. >> PARSEDIR.BAT ECHO :End GOTO ChoiceOut :ParseDir2 :: # FINAL PARSE DIR METHOD 2 (not adding space on second run) :: > PARSEDIR.BAT ECHO IF "%%1"=="?[" GOTO FirstRun >> PARSEDIR.BAT ECHO GOTO SecondRun >> PARSEDIR.BAT ECHO. >> PARSEDIR.BAT ECHO :FirstRun >> PARSEDIR.BAT ECHO IF "%%5"=="]?" GOTO End >> PARSEDIR.BAT ECHO SET _DIRMAGIC=%%5 >> PARSEDIR.BAT ECHO IF "%%5"=="\" SET _DIRMAGIC= >> PARSEDIR.BAT ECHO SHIFT >> PARSEDIR.BAT ECHO IF "%%5"=="]?" GOTO End >> PARSEDIR.BAT ECHO :FirstLoop >> PARSEDIR.BAT ECHO IF "%%5"=="\" SET _DIRMAGIC= >> PARSEDIR.BAT ECHO IF "%%5"=="\" SHIFT >> PARSEDIR.BAT ECHO IF "%%5"=="]?" GOTO End >> PARSEDIR.BAT ECHO IF NOT "%%5"=="]?" FOR %%%%X IN ( SET SHIFT GOTO:FirstLoop ) DO %%%%X _DIRMAGIC=%%_DIRMAGIC%%%%5 >> PARSEDIR.BAT ECHO GOTO End >> PARSEDIR.BAT ECHO. >> PARSEDIR.BAT ECHO :SecondRun >> PARSEDIR.BAT ECHO IF "%%2"=="]?" GOTO End >> PARSEDIR.BAT ECHO SET _DIRMAGIC=%%_DIRMAGIC%%%%2 >> PARSEDIR.BAT ECHO IF "%%2"=="\" SET _DIRMAGIC= >> PARSEDIR.BAT ECHO SHIFT >> PARSEDIR.BAT ECHO IF "%%2"=="]?" GOTO End >> PARSEDIR.BAT ECHO :SecondLoop >> PARSEDIR.BAT ECHO IF "%%2"=="\" SET _DIRMAGIC= >> PARSEDIR.BAT ECHO IF "%%2"=="\" SHIFT >> PARSEDIR.BAT ECHO IF "%%2"=="]?" GOTO End >> PARSEDIR.BAT ECHO IF NOT "%%2"=="]?" FOR %%%%X IN ( SET SHIFT GOTO:SecondLoop ) DO %%%%X _DIRMAGIC=%%_DIRMAGIC%%%%2 >> PARSEDIR.BAT ECHO GOTO End >> PARSEDIR.BAT ECHO. >> PARSEDIR.BAT ECHO :End :: # FINAL PARSE DIR TEST OUTPUT METHOD 1: :: for directory: :: "C:\Program Files\Online Services\MSN50\OCX\valid long name" :: ================================================================= :: Directory: :: "C:\Program Files\Online Services\MSN50\OCX\valid long name" :: :: Method1 Parsing... :: Parsed directory: :: "VALID LONG NAME" :: ================================================================= :: # FINAL PARSE DIR TEST OUTPUT METHOD 2 :: for directory: :: "C:\Program Files\Online Services\MSN50\OCX\not= valid, long; name" :: ================================================================= :: Directory: :: "C:\Program Files\Online Services\MSN50\OCX\not valid long name" :: Not valid directory name :: :: UseMethod2 :: Directory: :: "C:\PROGRA~1\ONLINE~1\MSN50\OCX\NOT_VA~1" :: :: Method2 Parsing... :: Parsed directory: :: "NOT_VA~1" :: ================================================================= :ChoiceOut SET _PARSE=%3 > CALLMAIN.BAT ECHO = | CHOICE /C=%3= CALL PARSEDIR.BAT ? :Loop SHIFT >> CALLMAIN.BAT ECHO = | CHOICE /C=%3= CALL PARSEDIR.BAT ?? IF NOT "%4"=="" GOTO Loop :: output: :: CALL PARSEDIR.BAT ?[=,D,I,R,E,C,T,O,R,Y,=]?= :: CALL PARSEDIR.BAT ??[=,N,A,M,E,=]?= :: CALL PARSEDIR.BAT %1 %2 3 4 5 6 7 8 9 ... CALL CALLMAIN.BAT ECHO Parsed directory: ECHO "%_DIRMAGIC%" DEL CALLMAIN.BAT DEL DIRECTORY.BAT DEL PARSEDIR.BAT :: # PLACE YOUR BATCH CODE HERE !!! :: # variables set: _DIR current dir name with path :: # _DIRMAGIC current dir name without path :: :: # NOTE: change lines where _DIR var is checked for valid :: maybe its possible to continue parsing without :: valid _DIR var (if you do not need !!! EXACT !!! dir name GOTO End :Error ECHO %_ERROR% :: beep (ALT + 7) ECHO :End |
23rd February 2005, 00:53 | #23 | Link |
Registered User
Join Date: Jan 2005
Posts: 368
|
Thanks guys! I've just had an enjoyable time playing around with these.
esby: dnd works nicely. There is one option which I would like. At the moment it stores full paths in the m3u, But I would like an option whether or not to write full paths into the m3u. This would be handy if I save the mp3s and m3u onto CD backup, and they might be copied back to a different location in the future onto a different Windows setup on a PC. dndc would not work for with just dndc c:\ (no m3us created anywhere). But if I used dndc c:\ -wmyfile.m3u , then it worked in that it does create an m3u in each folder containing mp3s and it gives each m3u the name of that folder (excellent! ) and also the m3u doesn't contain full-paths, ...but it doesn't create any 'wmyfile.m3u' which I dont think is the expected behaviour - though what it does do is great and exactly what I want! :Iradic I tried the bat and it gave me some errors C:\asblah>DIRMAGIC.BAT 'Volume' is not recognized as an internal or external command, operable program or batch file. 'Volume' is not recognized as an internal or external command, operable program or batch file. Directory: "C:\asblah" Not valid directory name UseMethod2 'TRUENAME' is not recognized as an internal or external command, operable program or batch file. C:\asblah> I had saved the code as DIRMAGIC.BAT and run it from my c:\asblah folder, which contains an mp3. After I try to run it I lok in c:\asblah and there are 3 bat files have been created there - CALLMAIN.BAT which contains Invalid parameter - ThisIsTrick DIRECTORY.BAT which contains SET _DIR=%2 SHIFT :Loop IF NOT "%2"=="" FOR %%X IN ( SET SHIFT GOTO:Loop ) DO %%X _DIR=%_DIR% %2 INVALID.BAT which contains SET _DIR=%4 ------ Also, where you say "just one thing ... you need to put your code to create m3u playlist..." and have put in your bat :: # PLACE YOUR BATCH CODE HERE !!! I was not sure exactly how to put it so I have in there changed the line to: :: # dir /B /O *.mp3 > ppp.m3u I am not very advanced at this coding so I wasn't sure if that was right Anyway guys, I really appreciate the time you have taken on this
__________________
Thankyou!, I am grateful for any help |
23rd February 2005, 12:33 | #24 | Link |
Registered User
Join Date: Jan 2004
Posts: 332
|
i found this on the net
TRUENAME This is an undocumented command in MSDOS since version 5. The bad news is that TRUENAME absolutely will not work with long file names. It simply truncates the names until they fit in an 8.3 mask, and will happily give you the bogus name as a result. The good news is that if you change into a directory, running TRUENAME without arguments will give you the real legitimate short name of the directory. you are probably on winxp/2k since this is dos command... you shoud try to debug bat file... i have winme and it works... i will try on my win2k machine to see how it works also i thought you are experienced with batch files... well main thing here is.... if you are running winxp/2k console you should execute for with /f switch ... if you are on win9x/dos console this bat should work... i will try to play with this bat on my winme and win2k to improve it and will post you result... (i see now there are some things to improve)... bye |
23rd February 2005, 13:20 | #25 | Link |
Registered User
Join Date: Oct 2001
Location: france
Posts: 521
|
new version upped.
two bug fixes: * command line parser corrected. All the parameters are analyzed now. * added the call to the needed method for the 'auto' mode in the non console version. esby NB: in console mode, you can use 'dndc . -wtoto.m3u' It will scan the current directory and will use relative path (vs absolute). I could enable the option for the gui, but supposing you drag others directory or folders, it could create invalid m3u files..., as the root folder would not be necessary in the same place.
__________________
http://esby.free.fr/ |
24th February 2005, 02:56 | #26 | Link |
Registered User
Join Date: Jan 2005
Posts: 368
|
esby: Both console and DND version work great! I 'get' the go (auto) & go (save) now ; and it's so nice and easy with Windows Explorer using auto!. Default behaviour is not to save path info. Everything is exactly what I hoped, nice and easy and quick to use. The console version with dndc c:\ or dndc d:\ likewise
Iradic: Yeah I am running XP pro (sp1). I'm far from advanced with any kind of programming, I sort of wade in and read & read and try things but always fail to get very far without losing the plot. I can do some HTML and simple batch files but not much more beyond that! I guess by debugging the bat you mean go line by line and see where it fails and why. I will certainly do my best. Thanks very much for your time spent on it.
__________________
Thankyou!, I am grateful for any help |
24th February 2005, 18:54 | #27 | Link |
Registered User
Join Date: Jan 2004
Posts: 332
|
hi i made a new one...
summary: it should work on winxp/2k (uses for with /f switch) then accepts directory as input so you can use "send to" mouse right-click menu under win9x/dos characters " " (space) "," ";" "=" will be replaced by space (one or more consecutive with one space) hope it works... bye Code:
:: /? M3UMAGIC.BAT - create m3u playlist with directory name :: /? :: /? Usage: Place M3UMAGIC.BAT in directroy where you want playlist :: /? to be created and execute it, use "/?" for this help screen :: /? or use directory (full path) where you want playlist to be :: /? created as input parameter :: /? :: /? WARNING: under Win9x/DOS don't use "Environment_OK" or "Parsing" :: /? as first input parameter :: /? :: /? Limitations: really really long paths or names are not supported :: /? (very very rare case) :: /? :: /? # see DIRMAGIC.BAT for more info :: /? @ECHO off ECHO. IF "%OS%"=="Windows_NT" GOTO WinNT IF "%1"=="Environment_OK" GOTO Ok_to_Go IF "%1"=="Parsing" GOTO Parse IF "%1"=="/?" GOTO Usage IF EXIST "%1.\nul" %1\ IF EXIST "%1.\nul" CD %1 ECHO Win9x/DOS detected... ECHO Runing a new shell with environment big enough... :: # run a new shell with environment big enough :: 1024 bytes - increase if you get "Out of environment space" message COMMAND /e:1024/c %0 Environment_OK GOTO Dend :Ok_to_Go > CALLMAIN.BAT DIR *.none | FIND "Directory of" | FIND ":\" :: output: :: Directory of DIRECTORY_NAME :: DIRECTORY.BAT %1 %2 > DIRECTORY.BAT ECHO SET _DIR=%%2 >> DIRECTORY.BAT ECHO SHIFT >> DIRECTORY.BAT ECHO :Loop >> DIRECTORY.BAT ECHO IF NOT "%%2"=="" FOR %%%%X IN ( SET SHIFT GOTO:Loop ) DO %%%%X _DIR=%%_DIR%% %%2 CALL CALLMAIN.BAT ECHO Directory: ECHO "%_DIR%" %0 Parsing %_DIR% GOTO Dend :Parse ECHO %1... :: # FINAL PARSE DIR :: > PARSEDIR.BAT ECHO IF "%%1"=="?[" GOTO FirstRun >> PARSEDIR.BAT ECHO GOTO SecondRun >> PARSEDIR.BAT ECHO. >> PARSEDIR.BAT ECHO :FirstRun >> PARSEDIR.BAT ECHO IF "%%5"=="]?" GOTO End >> PARSEDIR.BAT ECHO SET _DIR=%%5 >> PARSEDIR.BAT ECHO IF "%%5"=="\" SET _DIR= >> PARSEDIR.BAT ECHO SHIFT >> PARSEDIR.BAT ECHO IF "%%5"=="]?" GOTO End >> PARSEDIR.BAT ECHO :FirstLoop >> PARSEDIR.BAT ECHO IF "%%5"=="\" SET _DIR= >> PARSEDIR.BAT ECHO IF "%%5"=="\" SHIFT >> PARSEDIR.BAT ECHO IF "%%5"=="]?" GOTO End >> PARSEDIR.BAT ECHO IF NOT "%%5"=="]?" FOR %%%%X IN ( SET SHIFT GOTO:FirstLoop ) DO %%%%X _DIR=%%_DIR%%%%5 >> PARSEDIR.BAT ECHO GOTO End >> PARSEDIR.BAT ECHO. >> PARSEDIR.BAT ECHO :SecondRun >> PARSEDIR.BAT ECHO IF "%%2"=="]?" GOTO End >> PARSEDIR.BAT ECHO SET _DIR=%%_DIR%% %%2 >> PARSEDIR.BAT ECHO IF "%%2"=="\" SET _DIR= >> PARSEDIR.BAT ECHO SHIFT >> PARSEDIR.BAT ECHO IF "%%2"=="]?" GOTO End >> PARSEDIR.BAT ECHO :SecondLoop >> PARSEDIR.BAT ECHO IF "%%2"=="\" SET _DIR= >> PARSEDIR.BAT ECHO IF "%%2"=="\" SHIFT >> PARSEDIR.BAT ECHO IF "%%2"=="]?" GOTO End >> PARSEDIR.BAT ECHO IF NOT "%%2"=="]?" FOR %%%%X IN ( SET SHIFT GOTO:SecondLoop ) DO %%%%X _DIR=%%_DIR%%%%2 >> PARSEDIR.BAT ECHO GOTO End >> PARSEDIR.BAT ECHO. >> PARSEDIR.BAT ECHO :End :ChoiceOut > CALLMAIN.BAT ECHO = | CHOICE /C=%2= CALL PARSEDIR.BAT ? :Loop SHIFT >> CALLMAIN.BAT ECHO = | CHOICE /C=%2= CALL PARSEDIR.BAT ?? IF NOT "%3"=="" GOTO Loop :: output: :: CALL PARSEDIR.BAT ?[=,D,I,R,E,C,T,O,R,Y,=]?= :: CALL PARSEDIR.BAT ??[=,N,A,M,E,=]?= :: CALL PARSEDIR.BAT %1 %2 3 4 5 6 7 8 9 ... CALL CALLMAIN.BAT ECHO Directory name: ECHO "%_DIR%" ECHO. ECHO Createing m3u playlist... ECHO If you get "File creation error" message then dir path or name is too long ECHO Shorten path or name and run this batch file again in that case DIR /B /O *.mp3 > "%_DIR%.m3u" ECHO. GOTO End :Usage IF NOT EXIST "%0" SET _HELP=%0.bat IF EXIST "%0" SET _HELP=%0 FIND ":: /?" "%_HELP%" | FIND /V "/V" GOTO Dend :WinNT ECHO WinNT detected... ECHO. ECHO Createing m3u playlist... IF EXIST "%1.\nul" %1\ IF EXIST "%1.\nul" CD %1 FOR /F %%I IN ("%CD%") DO DIR /B /O *.mp3 > %%~NI.m3u GOTO Dend :End IF EXIST DIRECTORY.BAT DEL DIRECTORY.BAT IF EXIST PARSEDIR.BAT DEL PARSEDIR.BAT IF EXIST CALLMAIN.BAT DEL CALLMAIN.BAT ECHO Done :Dend Last edited by iradic; 24th February 2005 at 18:57. |
Thread Tools | Search this Thread |
Display Modes | |
|
|