Sign in to follow this  
Followers 0
Tukata

Creating A List From A Cd Files

7 posts in this topic

Hi,

I need a small project that gets the drive letter for the clipboad, or even better, recognize on which drive a CD is inserted, and create a list of all files (txt) in the working folder.

Thanks for the help

Tuk

Share this post


Link to post
Share on other sites



Hi,

I need a small project that gets the drive letter for the clipboad...

I would love to see that

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I would love to see that

8)

Haha same here

To answer your question:

DriveGetDrive ( "type" )

Type will be CDRom

DriveStatus ( "path" )

Get path from DriveGetDrive and use a If DriveStatus = READY

Go on from that.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Edit: something is wrong ;p wait trying to fix it.

Edit2: Function has to be started with Driver letter ":" and "\" --> _CDTOTXT("F:\")

Else it will get only some of dirs.

I would love to see that

8)

Here's little thing i cut out from my other script :think: Some variable names might be not relevant to topic but i didn't realy wanted to play with it so much. All you gotta do now is add those functions that Manader posted. and send them to _CDTOTXT(). Also if you want better output to file modify _AddLogToFile($Text) function. Cheers

#Include <Array.au3>
#include <Constants.au3>
#Include <Date.au3>
#include <File.au3>
Global $log_file = @ScriptDir & "\cd.log"

_CDTOTXT("F:\")

Func _CDTOTXT($path_to_cdrom)
        $DirOutput = Run(@ComSpec & " /c DIR /A:D /S " & $path_to_cdrom, '', @SW_HIDE, 2)
        Local $DirOutputOnce
        While 1
            $DirData = StdoutRead($DirOutput)
            If @error Then ExitLoop
            If $DirData Then
                $DirOutputOnce &= $DirData
            Else
                Sleep(10)
            EndIf
        WEnd
     ; Remove spaces from output
        $DirOutputOnce = StringStripWS($DirOutputOnce, 3)
     ; Split output into array
        $DirSplit = StringSplit($DirOutputOnce, @CRLF,1)
        For $i = 1 To $DirSplit[0]
            If StringInStr($DirSplit[$i], $path_to_cdrom) Then
                $DirsLine = StringSplit($DirSplit[$i], ": ",1)
                If $DirsLine[0] = 2 Then; Testing amount of elements in array, if more then 2 Exits
                    If StringInStr($DirsLine[2], $path_to_cdrom) Then; Making sure that path exists in string
                        $cd_directories = $DirsLine[2]
                        
                        $search_all = FileFindFirstFile($cd_directories & "\*.*"); Searching for all files in directory
                        If $search_all = -1 Then
                        Else
                            
                            While 1
                                $search_file = FileFindNextFile($search_all)
                                If @error Then ExitLoop                             
                                $full_path_to_all =  $cd_directories & "\" & $search_file
                                _AddLogToFile($full_path_to_all)
                            WEnd
                        EndIF
                        FileClose($search_all)
                    EndIf
                EndIf
            EndIf
        Next
EndFunc
    
Func _AddLogToFile($Text)
        $file_log = FileOpen($log_file,1)
        FileWriteLine($file_log, "["& _NowTime(5) & "] - " & $Text & @CRLF)
        FileClose ( $file_log )
EndFunc
Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

Sorry for my English, I did not explain good.

I simply want to know on which drive user inserted a CD.

That's all.

Thank you

Tuk

Share this post


Link to post
Share on other sites

list CDrom drives and status

Local $cdrom
For $i = 65 to 89
    $Type = DriveGetType (Chr ($i) & ":")
    if $Type = "CDROM" then 
        $CDROM = $CDROM &  Chr ($i) & ":\ "  & DriveStatus ( Chr ($i) & ":" ) & @crlf

        Endif
    Next
    
    MsgBox (0,"Cdrom drives", $CDROM)

Share this post


Link to post
Share on other sites

Many thanks.

This was what I needed.

Tuk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0