Zobu Posted January 28, 2021 Share Posted January 28, 2021 Hi Guys, I want to rename every file moved to created folder automatically to for example "test 1" but the next file moved into that folder should be named "test 2" and so on.. the names of the files have no test or numbers and they all have different filenames so somehow delete the whole name and rename to test 1, test 2, and so on if moved to folder i just know how to create the folder #include <File.au3> _desktopDir() Func _desktopDir() Local Const $rFilePath = @DesktopDir & "\testfiles" If FileExists($rFilePath) Then Return False EndIf DirCreate($rFilePath) EndFunc Link to comment Share on other sites More sharing options...
genius257 Posted January 28, 2021 Share Posted January 28, 2021 Hi @Zobu. Seems like this would be a place to start: _WinAPI_FindFirstChangeNotification.htm See the example for usage. My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
Nine Posted January 28, 2021 Share Posted January 28, 2021 Only problem with that solution is that you cannot retrieve which file/folder has changed. To retrieve information about the specific change, use the _WinAPI_ReadDirectoryChanges function. But be careful with this API as it is a blocking function. To use a non-blocking API, you will have to go with ReadDirectoryChangesW Windows API. genius257 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted January 29, 2021 Share Posted January 29, 2021 (edited) I kind of did something like this once, maybe a more brute force than the API functions. Had a scan directory and it would name the files with the user name and a time stamp and then move them. I just did a while loop and a file list to array. You could do some cleaver stringinstr() functions and some variables or sorting to name the files. I think regex also could be useful here if you really wanted. You could use sleep() in the loop, use adlibregister for a function, or perhaps even check your file count relatedly and only execute a function when your file count changes. Could be a fun one to mess with. I think id have a filelisttoarray() check the count and when it changes execute the function. The function would find any files not matching a certain pattern and rename them to TestX and X would be determined by the file count. Edited January 29, 2021 by ViciousXUSMC Link to comment Share on other sites More sharing options...
junkew Posted February 7, 2021 Share Posted February 7, 2021 Why do you want to number or rename them? FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now