Sign in to follow this  
Followers 0
mschol

Need Help With Couple Of Problems

6 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ok... then maybe try this... if you are sure of the file name, spacing, and it exists

RunWait(@COMSPEC & " /c " & filegetshortname($commando))

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
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)

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