View Single Post
28 Oct 2011  

Windows 7 32 bit

I have an AutoIt3 function that returns the "base name" of a path. For example, _FileBaseName("C:\MyFolder\MyFile.txt") returns "MyFile"

You could use it to put the file into the proper folder

Whatever programming language you decide to use should either have a canned function that does the same, or have library functions you can use to roll your own without too much difficulty

Basically it just returns the characters after the last backslash up to but not including the first extension dot

; return the basename part of a file path
; works only for files with extension
; e.g. returns "test" for c:\folder\test.exe path
Func _FileBaseName($path)
	If $path = "" Then Return ""
	If StringLen($path) < 3 Then Return ""

	Local $pos = StringInStr($path, "\", 0, -1)
	$pos += 1
	Local $tmp = StringMid($path, $pos)
	Return StringLeft($tmp, StringInStr($tmp, ".", 0, -1) - 1)
EndFunc   ;==>_FileBaseName
So in AutoIt3 you would do something like
$basename = _FileBaseName($path)

FileMove($basename & ".*", $basename & "\*.*)

The "&" is string concatenation operator. So it becomes "move files with base name x inside folder named x"

Should be pretty simple if the folders are all on the same level.
My System SpecsSystem Spec