Jump to content

Random select multiplie files


Recommended Posts

Well i have now been seaching the internet for some hours and i cant figure out how to script what i need :/

so i came to the idea that maybe you guys could figure it out for me :)

i will go though it step by step

1 i need to go to my image folder

2 in that folder i want to select/highlight 50 random files

job done ;)

i need to select 50 random images in this folder 3 times everyday so it would be pretty helpful if anyone knows how to do that ;)

Link to post
Share on other sites

Edit: yeah I just read that last post. never mind then. Study the helpfile for a day and you will be well on your way to writing basic scripts.

I can assure you you're going to find it a lot more educational than the first month of school.

Edited by Tvern
Link to post
Share on other sites

Fair enough.

But if you look at and run the examples of the functions mentioned you will have a script in no time at all.

$array = _Filelisttoarray("path") will give you an array as mentioned.

Ramdom(1,$array[0],1) will give you a random number withing the bounds of your array.

A little if else logic will see you from there.

Write that, and you will get all the help you need here.

Good luck.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites

thx alot i will give it a shot :)

edit : ok i been reading the help file a little and messing around with lines of code you suggested and well im getting nowhere :s i understand nothing of what im doing actully in this program :/

Edited by spitzer89
Link to post
Share on other sites

You can send the five snots to the forum as a donation.

http://www.autoitscript.com/site/donate/

#include <File.au3>

Local $i_NumPics = 50
Local $a_RandomNumber[$i_NumPics]

$s_ImageArray = _FileListToArray("C:\my\folder\path", "*", 1) ; array of all files in your image folder
$b_Unique = True
For $i = 0 To UBound($a_RandomNumber) - 1
    Do
        $b_Unique = True ; presume number is unique 
        $irnd = Random(1, Int($s_ImageArray[0]), 1) ; select a random number withing imagearray bounds
        For $j = 0 To UBound($a_RandomNumber) - 1 ;loop throug
            If $irnd = $a_RandomNumber[$j] Then ; you already have that number
                $b_Unique = False ; booooooooooooooo
                ExitLoop
            EndIf
        Next
        If $b_Unique Then ; we dont have that number
            $a_RandomNumber[$i] = $irnd ; yaaaaaaaaaay
        EndIf
    Until $b_Unique ; keep going until random number is unique
Next

For $i = 0 To UBound($a_RandomNumber) -1
    ConsoleWrite($s_ImageArray[$a_RandomNumber[$i]] & @CRLF) ; list your image files
Next
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites

so atm it looks like this

#include <File.au3>

Local $i_NumPics = 50

Local $a_RandomNumber[$i_NumPics]

$s_ImageArray = _FileListToArray("C:\Users\Steffen\Desktop\imagestest", "*", 1) ; array of all files in your image folder

$b_Unique = True

For $i = 0 To UBound($a_RandomNumber) - 1

Do

$b_Unique = True ; presume number is unique

$irnd = Random(1, Int($s_ImageArray[0]), 1) ; select a random number withing imagearray bounds

For $j = 0 To UBound($a_RandomNumber) - 1 ;loop throug

If $irnd = $a_RandomNumber[$j] Then ; you already have that number

$b_Unique = False ; booooooooooooooo

ExitLoop

EndIf

Next

If $b_Unique Then ; we dont have that number

$a_RandomNumber[$i] = $irnd ; yaaaaaaaaaay

EndIf

Until $b_Unique ; keep going until random number is unique

Next

For $i = 0 To UBound($a_RandomNumber) -1

ConsoleWrite($s_ImageArray[$a_RandomNumber[$i]] & @CRLF) ; list your image files

Next

but nothing happens when i run it :s ?

Link to post
Share on other sites

Yeah, there are a couple of members who have fully coded, debugged, feature filled custom solutions ready for newbs who ask for help in like five minutes flat. I can't explain it how they do it.

Link to post
Share on other sites

well cant figur it out :s anyways i have fixed the problem myself i found a program called mix2stick that kinda does what i need but thx for trying

So don't give up so eazily!

You only missed one slash:

#include <File.au3>
Local $i_NumPics = 50
Local $a_RandomNumber[$i_NumPics]
$s_ImageArray = _FileListToArray("C:\Gifs\Users\Steffen\Desktop\imagestest\", "*", 1) ;<<<<  === study this line carefully
$b_Unique = True
For $i = 0 To UBound($a_RandomNumber) - 1
    Do
        $b_Unique = True ; presume number is unique
        $irnd = Random(1, Int($s_ImageArray[0]), 1) ; select a random number withing imagearray bounds
        For $j = 0 To UBound($a_RandomNumber) - 1 ;loop throug
            If $irnd = $a_RandomNumber[$j] Then ; you already have that number
                $b_Unique = False ; booooooooooooooo
                ExitLoop
            EndIf
        Next
        If $b_Unique Then ; we dont have that number
            $a_RandomNumber[$i] = $irnd ; yaaaaaaaaaay
        EndIf
    Until $b_Unique ; keep going until random number is unique
Next

For $i = 0 To UBound($a_RandomNumber) - 1
    ConsoleWrite($s_ImageArray[$a_RandomNumber[$i]] & @CRLF) ; list your image files
Next

Adding note == >

Edited by JoHanatCent
Link to post
Share on other sites

So don't give up so eazily!

You only missed one slash:

#include <File.au3>
Local $i_NumPics = 50
Local $a_RandomNumber[$i_NumPics]
$s_ImageArray = _FileListToArray("e:\Gifs\Users\Steffen\Desktop\imagestest\", "*", 1) ;<<<<  === study this line carefully
$b_Unique = True
For $i = 0 To UBound($a_RandomNumber) - 1
    Do
        $b_Unique = True ; presume number is unique
        $irnd = Random(1, Int($s_ImageArray[0]), 1) ; select a random number withing imagearray bounds
        For $j = 0 To UBound($a_RandomNumber) - 1 ;loop throug
            If $irnd = $a_RandomNumber[$j] Then ; you already have that number
                $b_Unique = False ; booooooooooooooo
                ExitLoop
            EndIf
        Next
        If $b_Unique Then ; we dont have that number
            $a_RandomNumber[$i] = $irnd ; yaaaaaaaaaay
        EndIf
    Until $b_Unique ; keep going until random number is unique
Next

For $i = 0 To UBound($a_RandomNumber) - 1
    ConsoleWrite($s_ImageArray[$a_RandomNumber[$i]] & @CRLF) ; list your image files
Next

Adding note == >

thx i will look into this later, but for now i have a drawing class to attend to :) but i kinda like this forum people are pretty helpful ;)

hehe i know i give up pretty easy but code really isnt my strong side im more a well visual kinda guy ;)

Link to post
Share on other sites

Well you should bear in mind that a programing language will most likely come into play at some point during your Drawing education, and it wont harm you to get a head start.

You could think of Autoit as a hobby if you want, but I guarantee it will help you in the future.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...