Jump to content

Rename every File moved to Folder automatically


Recommended Posts

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 post
Share on other sites

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.

Link to post
Share on other sites

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 by ViciousXUSMC
Link to post
Share on other sites
  • 2 weeks later...

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...