Sign in to follow this  
Followers 0
supadodger

simple help... rename random file from array...

15 posts in this topic

i know its probably a simple fix but i cant figure out why the msgbox is returning a numeric value instead of a filename...

$FileList=_FileListToArray("./","*.mp4",1)
$end = $filelist[0]
$x = random (1,$end,1)
$name = $filelist[$x]
MsgBox (4096,"",$name)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Capitalize the f in the two $filelist lines (2 & 4), or uncapitalize the F in the first line $Filelist.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

_FileListToArray could be at error and returning 0

i should have said its not returning 0...there are 21 mp4 files and it is returning randomly 1-21...

i just need it to return a random filename not a random number...

also tried uncapitalizing the 1 F and no change...

Edited by supadodger

Share this post


Link to post
Share on other sites

supadodger,

your posted script works fine for me. The MessageBox shows a random filename every time I start the script!

(I only changed the search pattern)

#Include <File.au3>
#Include <Array.au3>

$FileList=_FileListToArray("./","*.*",1)
$end = $filelist[0]
$x = random (1,$end,1)
$name = $filelist[$x]
MsgBox (4096,"",$name)

A-Jay


Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites

the script works fine for me too

i think you can use you can use _ArrayDisplay($filelist, "") to check the return value of _FileListToArray and see if it fails

Share this post


Link to post
Share on other sites

supadodger,

your posted script works fine for me. The MessageBox shows a random filename every time I start the script!

(I only changed the search pattern)

#Include <File.au3>
#Include <Array.au3>

$FileList=_FileListToArray("./","*.*",1)
$end = $filelist[0]
$x = random (1,$end,1)
$name = $filelist[$x]
MsgBox (4096,"",$name)

A-Jay

if i leave it at *.* its displaying filenames but if i make it *.mp4 its giving me numbers hmmm

at least im making progress...

Share this post


Link to post
Share on other sites

Sorry to ask an obvious question, but .mp4 files do exist in the scripts directory?


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Okay, I changed search pattern back to *.mp4 and I created some .mp4 files in the script directory --- and: Works fine!

Compiled and uncompiled works.

WinXP x86

AutoIt 3.3.4.0

hmm....


Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites

Come on, John... for testing the script it is not necessary to have "real" .mp4-files. The right filename will do it ;)

A-Jay


Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites

rebooted and works fine... oh well... thanks guys.. ;)

Share this post


Link to post
Share on other sites

Posted Image

I lol'd.

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

I'm still lol'ing!

I see your collection of eggs has grown

Hell yeah, new UnCommon eggs each time.

Not all are my though, im sharing with my girlfriend ;)


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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