; Move To Initial
; Autor: Stefan for
www.DonationCoder.com; Version: 0.1 , 2006-04-25
; Purpose: Move all files and folders of the current directory to an sub folder depending on the initial char of the file/folder name.
; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; ::: S E T T I N G S :::
; ::: Overwrite existing files or cancel the move ?
FileMoveDirOverwrite=0
FileMoveOverwrite=0
; 0 (default): Do not overwrite existing files/folders. (Cancel the current move and Skip the current file/folder. You have to do some work manually)
; 1: Overwrite existing files. (Maybe you overwrite older files/folders you wanna keep? Be carefull with this option!)
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; ::: S C R I P T :::
; lines starting with a semicolon is only comment for your pleasure.
;Loop, FilePattern [, IncludeFolders?, Recurse?]
Loop, *.*,1,0
{
; skip the script-file itselfs, to not move it too.
; IF current LOOP the same as the name of the script ... GoTo start
IF A_LoopFileName=%A_ScriptName%
{
continue
; 'continue' means "Skip current loop and GoTo start"
}
; skip folder/file with name less then 2 char, to avoid loops (i.e. don't move e.g. folder 'A' to folder 'A'...)
;StringLen, OutputVar, InputVar
StringLen, Len, A_LoopFileName
IF (%LEN% < 2) continue
; we need only the first char of the folder/file name to create an new folder with this initial.
;StringLeft, OutputVar, InputVar, Count
StringLeft, InitialDir, A_LoopFileName, 1
; IF NOT ALREADY EXIST %InitialDir% MAKE A NEW folder %InitialDir%
IfNotExist,%InitialDir%
{
FileCreateDir, %InitialDir%
}
; MOVE Folder with name %A_LoopFileName% TO %InitialDir%
;FileMoveDir, Source, Dest [, Flag]
FileMoveDir, %A_LoopFileName%, %InitialDir%\%A_LoopFileName% , %FileMoveDirOverwrite%
; MOVE File with name %A_LoopFileName% INTO %InitialDir%
;FileMove, SourcePattern, DestPattern [, Flag]
FileMove, %A_LoopFileName%, %InitialDir% , %FileMoveOverwrite%
;Esc::ExitApp
; go to the begin and execute the next Loop
}