Detecting File Extensions Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DarkSapient
Posts: 9
Joined: 14 Aug 2016, 11:47

Detecting File Extensions

24 May 2017, 14:34

So I mistakenly followed a misleading tutorial on installing Linux on an SSD and I accidentally wiped my Windows partition with 6 years worth of data (Shouldn't have been working on it while I was hungry, tired, and time pressured). Anyway, I recovered the partition but as expected, all the data is randomly spread out on the recovery drive with no names or anything to tell me what is what. Now I am left with a crap ton of files that I need to sort somehow. I want to start by sorting all the text files into one folder. I wrote a test script to see if I could detect whether or not a file had a .txt extension but it doesn't seem to be working. The problem is that it keeps printing out all of the filenames in the folder and not just .txt files. I'm relatively new to AHK so I could be doing something wrong. Any help would be appreciated. Thanks!

Code: Select all

Esc::ExitApp

Enter::
	CurrDir = F:\FullRecovery\recup_dir.1\*.*
	Loop, %CurrDir% {
		if (%A_LoopFileExt% == txt) {
			SplashTextOn, , , %A_LoopFileName%
		}
	}
Return
User avatar
masato
Posts: 21
Joined: 08 Sep 2015, 13:38

Re: Detecting File Extensions  Topic is solved

24 May 2017, 14:45

Hi there,
You must use one of either:

Code: Select all

if (A_LoopFileExt = "txt" )
if %A_LoopFileExt% == txt
(%A_LoopFileExt%) means "the content of a variable with the same name as this file extension"
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Detecting File Extensions

24 May 2017, 14:46

Code: Select all

Enter::
	CurrDir = F:\FullRecovery\recup_dir.1\*.*
	Loop, %CurrDir% {
		if InStr(A_LoopFileExt,"txt") {
		; if (A_LoopFileExt = "txt") {
			ToolTip %A_LoopFileName%
			Sleep, 300
			ToolTip
		}
	}
        Return
        
Esc::ExitApp
DarkSapient
Posts: 9
Joined: 14 Aug 2016, 11:47

Re: Detecting File Extensions

24 May 2017, 14:48

Worked like a charm. Thank you very much.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 242 guests