Jump to content

Need Help With Couple Of Problems


Recommended Posts

hi,

i'm just started to do some more advanced things with autoit then only moving the mouse and sending keys and i'm running in a couple of problems.

  • when running $dircom the command also puts folders in the textfile, when i try running the command from a cmd prompt it doesnt include them, also tryed the _runDOS() command
  • when running winrar it says : file cannot be found, but again when running from cmd prompt the exact same command it works.
anyone who can help me out?

(for example is there a nicer way to get the file list in the directory?)

my script has to do the following:

  • select a directory where files are located
  • get a list of al the videofiles
  • create the correct amount of folders to store the rarred files
  • rar every file to their corresponding folder (so i_am_a_video_01.avi should go into folder 01 etc.)
here is my current code:

#include <Array.au3>
#Include <process.au3>
#include <file.au3>

$pad = FileSelectFolder("Selecteer pad","",2)
if @error == 1 then
exit
Endif

If FileExists($pad & "\fileser.txt") Then
    FileDelete($pad & "\fileser.txt")
EndIf

$dircom = "dir *.avi *.mpg *.ogm /b > """ & $pad & "\fileser.txt"" """ & $pad & "\"""
$val = RunWait(@COMSPEC & " /c " & $dircom)
InputBox("title", "Prompt",$dircom) 

Dim $files 
_FileReadToArray($pad & "\fileser.txt",$files)
_ArraySort($files,0);
$i = 1;
Do
    if $i < 10 then
        $a = 0 & $i
    else
        $a = $i
    endif
$dir = DirCreate($pad & "\" & $a)
$i = $i + 1
Until $i = _ArrayMaxIndex($files,0);


$i = 1;
Do
    if $i < 10 then
        $a = 0 & $i
    else
        $a = $i
    endif
$commando = """c:\program files\WINRAR\RAR.EXE"" a -ep -ilog -av -m5 -md4096 -v15000000 """ & $pad & "\" & $a & "\" & $a & """ """ & $pad & "\" & $files[$i] & """";
RunWait(@COMSPEC & " /c " & $commando)
InputBox("title", "Prompt", $commando)
if @error == 1 then
exit
Endif
$i = $i + 1
Until $i = _ArrayMaxIndex($files,0);

p.s. i know it might me a little messy code but i will fix that when i;m done scripting

Link to comment
Share on other sites

JUST VISUALLY.... this

$dircom = "dir *.avi *.mpg *.ogm /b > """ & $pad & "\fileser.txt"" """ & $pad & "\"""

seems like it should be this

$dircom = "dir *.avi *.mpg *.ogm /b > """ & $pad & "\fileser.txt""

the ">" is the file to output to

this is creating numberous "folders" only

$dir = DirCreate($pad & "\" & $a)

the last portion of the $commando string... looks very very over-done

& $pad & "\" & $a & "\" & $a & """ """ & $pad & "\" & $files[$i] & """";

i dont see how that could even work

again... just a visual opbservation

8)

NEWHeader1.png

Link to comment
Share on other sites

JUST VISUALLY.... this

$dircom = "dir *.avi *.mpg *.ogm /b > """ & $pad & "\fileser.txt"" """ & $pad & "\"""

seems like it should be this

$dircom = "dir *.avi *.mpg *.ogm /b > """ & $pad & "\fileser.txt""

the ">" is the file to output to

it seems weird indeed but the extra $pad is needed so that it will output the filelist of the correct folder (when running from a different folder, and thats really gonna happen)

this is creating numberous "folders" only

$dir = DirCreate($pad & "\" & $a)

i dont mind that, did that on purpose

the last portion of the $commando string... looks very very over-done

& $pad & "\" & $a & "\" & $a & """ """ & $pad & "\" & $files[$i] & """";

i dont see how that could even work

again... just a visual opbservation

8)

i know it kinda confused me too but its neccesery because when i have a path with a space in it it needs to be quoted with "

so yeah that kinda looks weird and when outputting to the input box, the command is completely fine (with quotes etc. )

but when using the @comspec it says the folder C:\program cannot be found

Edited by mschol
Link to comment
Share on other sites

ok the first problem (of the dir command) is solved by using the following:

$dir = "dir *.avi *.mpg *.ogm /b > ";
$outputfile = '"' & $PathToFiles  & '\fileser.txt"';
$val = RunWait(@COMSPEC & ' /c cd "' & $PathToFiles & '" &' & $dir & $outputfile)

what does it do: it runs a cd command (to go to the correct folder) and right after that , in the same line it does the dir /b command

this works, one problem solved :)

probably i can change the $output file in only a file name, didnt test it yet..

$pad == $PathToFiles btw, changed the names

Edited by mschol
Link to comment
Share on other sites

what does it do: it runs a cd command (to go to the correct folder) and right after that , in the same line it does the dir /b command

this works, one problem solved :)

probably i can change the $output file in only a file name, didnt test it yet..

You could make it simpler and use the working directory parameter instead.

$dir = "dir *.avi *.mpg *.ogm /b > ";
$outputfile = 'fileser.txt';
$val = RunWait(@ComSpec & ' /c ' & $dir & $outputfile, $PathToFiles)

Or 1 line if suitable

$val = RunWait(@ComSpec & ' /c dir *.avi *.mpg *.ogm /b > fileser.txt', $PathToFiles)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...