rename the bigger file in the same directory Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ronkwan
Posts: 8
Joined: 04 Nov 2016, 03:41

rename the bigger file in the same directory

Post by ronkwan » 07 Jun 2020, 05:57

e.g., three files like the following;

c:\test\0.results.txt size : 2 bytes
c:\test\1.results.txt size : 8 bytes
c:\test\2.results.txt size : 6 bytes

i need to rename the bigger file to a name from the clipboard.

i've tried to read the files through a loop like the following but don't really know how to extract and compare them, please help, much thanks!

Code: Select all

path = c:\test
NewName := Clipboard
loop, %path%\*.results.txt {
	File%A_Index% := A_LoopFileName
	Size%A_Index% := A_LoopFileSize
        ....
        FileMove .....
}

User avatar
Chunjee
Posts: 1500
Joined: 18 Apr 2014, 19:05
Contact:

Re: rename the bigger file in the same directory  Topic is solved

Post by Chunjee » 07 Jun 2020, 06:20

You have the filemove inside the loop checking all the file sizes. You should find the biggest file, then move it.

Code: Select all

path = c:\test
biggestFile := ""
biggestFileSize := 0
loop, %path%\*.results.txt {
	if (biggestFileSize < A_LoopFileSize) {
		biggestFileSize := A_LoopFileSize
		biggestFile := A_LoopFileFullPath
	}
}
FileMove, %biggestFile%, % A_ScriptDir "\biggestFile.txt"

Post Reply

Return to “Ask for Help (v1)”