Kenton Posted May 21, 2018 Share Posted May 21, 2018 Hi, I want to write a small bot that renames a selected file starting with year, month, date as follows: FileMove ("C:\test\Somefile.txt", "C:\test\" & @YEAR & @MON & @MDAY & " - " & "Somefile.txt") This works perfectly but I need the current path + filename as a string. The user will be on a filename in the windows explorer when they activate this bot. I am currently activating the bot through a windows shortcut key after I compiled the scrip. Link to comment Share on other sites More sharing options...
Kenton Posted May 21, 2018 Author Share Posted May 21, 2018 * I need the current path + filename as a string variable Link to comment Share on other sites More sharing options...
Kenton Posted May 21, 2018 Author Share Posted May 21, 2018 So I got it to partly work via send key: Quote Send("{F2}") Send("^C") Send(@YEAR & @MON & @MDAY & " - ") Send("^V") Send ("{ENTER}") But I still have some major issues: 1. I still need a way to add a Shortcut key that will trigger the code from within the windows explorer. Currently, it's only working on itself. 2. I don't like so many Send keys 3. I'll prefer to use variables not the clipboard In my view, the above FileMove is still a better than this Send key Any advice will be highly appreciated..... Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 21, 2018 Moderators Share Posted May 21, 2018 (edited) @Kenton welcome to the forum. Look at _FileListToArray in the help file. You basically read in all files in that directory to an Array, then loop through the array with your FileMove command. Here is a generic example. Imagine a Test folder on the desktop titled test, with a number of text files that I want to rename in numbered sequence: #include <File.au3> Local $sPath = @DesktopDir & "\Test" Local $aFiles = _FileListToArray($sPath, "*.txt", $FLTA_FILES, True) For $a = 1 To $aFiles[0] FileMove($aFiles[$a], $sPath & "\" & $a & ".txt") Next You should be able to modify this to suit your needs; if you run into trouble, please post your code and we will do our best to assist Edited May 21, 2018 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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