pullmyefinger

looking for a way to find certain files

4 posts in this topic

I am looking for a set of commands that i can use to

1. Process all files in a particular directory

2. Count the number of characters in the Name part of the filename

3. Run a loop for that many characters.

4. For 1 to X characters in the name, check for an ASCII "(" and ")" (meaning a copy of another file)

5. If I find both characters and it happens to be file(2).xxx or whatever, Delete that file.

6.  Outer loop for the number of files in the folder.

7.  Inner loop to check for the aforementioned characters.

I can do the inner and outer loops but I need some help with the file processing commands.

Any help would be appreciated as to where to look to find these commands.  

Share this post


Link to post
Share on other sites



I am looking for a set of commands that i can use to

1. Process all files in a particular directory

2. Count the number of characters in the Name part of the filename

3. Run a loop for that many characters.

4. For 1 to X characters in the name, check for an ASCII "(" and ")" (meaning a copy of another file)

5. If I find both characters and it happens to be file(2).xxx or whatever, Delete that file.

6.  Outer loop for the number of files in the folder.

7.  Inner loop to check for the aforementioned characters.

I can do the inner and outer loops but I need some help with the file processing commands.

Any help would be appreciated as to where to look to find these commands.  

Share this post


Link to post
Share on other sites

pullmyefinger,

Please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "Do not post general support questions here".  I have moved it for you, but would ask you to be more careful in future.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

9 hours ago, pullmyefinger said:

where to look to find these commands

Your help file is the best resource for fundamental commands and functions you can use.  Many UDFs (user defined functions) are also included in the help file and packaged with AutoIt to piece these fundamental commands/functions into something useful. 

_FileListToArray is a good one for producing a file listing.

Filenames are just strings, so string manipulation functions would be useful for counting characters; StringLen comes to mind.

To parse strings, arguably RegEx is the best way to go, but also arguably the most complex.  Luckily you can use basic comparators and search functions--like StringInstr-to find patterns without using RegEx...but RegEx is still worth a look.

The last piece of advice I have for now if look at the File* functions and see if you can find the right one to use to Delete files. ;)

Have a look around your help file and inspect / try out the examples to get a better understanding.  If you get stuck, let us know.

 

BTW, the _FileListToArray function supports a filter, which means if you have a pattern of characters to search for which will work with the filter format of the function...seems particularly useful for what you want to accomplish as I understand.

 

 

edit: 2000th post. woot

Edited by spudw2k

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