Jump to content

Strip directories from array of files


NELyon
 Share

Recommended Posts

Hey guys, it's been a while since I've asked a question. It's actually been a while since I did anything in Autoit.

Basically, I'm rewriting a bash script I wrote to upload images onto 4chan.

I have an array of files to upload, but I cannot figure out how to strip any array elements that lack either ".jpg", ".png", or ".gif" at the end.

EDIT: Oh yeah, the issue is that the recursive _FileListToArray-like function I am using adds the actual directories to the array along with the files themselves.

I've tried something along the lines of:

For $i=1 to UBound($aArray)-1
     If StringRight($aArray, 3) <> "jpg" or ...etc
          _ArrayDelete(Yadda yadda yadda)
     EndIf
Next

But there's obviously the issue of the upper bound of the array changing when you delete the elements.

I know, this is probably easy, but my brain is pretty fried right now and I can't figure it out.

Edited by KentonBomb
Link to comment
Share on other sites

Hey guys, it's been a while since I've asked a question. It's actually been a while since I did anything in Autoit.

Basically, I'm rewriting a bash script I wrote to upload images onto 4chan.

I have an array of files to upload, but I cannot figure out how to strip any array elements that lack either ".jpg", ".png", or ".gif" at the end.

EDIT: Oh yeah, the issue is that the recursive _FileListToArray-like function I am using adds the actual directories to the array along with the files themselves.

I've tried something along the lines of:

For $i=1 to UBound($aArray)-1
     If StringRight($aArray, 3) <> "jpg" or ...etc
          _ArrayDelete(Yadda yadda yadda)
     EndIf
Next

But there's obviously the issue of the upper bound of the array changing when you delete the elements.

I know, this is probably easy, but my brain is pretty fried right now and I can't figure it out.

I expect the problem is that you are going through the array in the wrong direction. Go from UBound -1 down to 1 and then the next element won't have been shifted because you deleted one.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...