반응형
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- SetControlDelay
- autohotkey
- SetKeyDelay
- EnvAdd
- StringGetPos
- if
- SetMouseDelay
- EnvSet
- EnvMult
- API
- IF (식)
- EnvSub
- Var:=식
- ControlSend
- DetectHiddenWindows
- IfInString
- 식의 설명
- 함수
- SetTitleMatchMode
- SetEnv
- 식
- Threads
- EnvDiv
- Blocks
- ControlGetText
- IfWinExist
- Menu
- 배열
- MouseClick
- if(식)
Archives
- Today
- Total
ㄴrㅎnㅂrㄹrㄱi
Loop(files) 패턴에 일치하는 파일 각각 붙어 융통반네 해를 실시한다 본문
반응형
Loop(files)
패턴에 일치하는 파일 각각 붙어 융통반네 해를 실시한다
Loop, FilePattern [, IncludeFolders?, Recurse?]
Parameters
| 인수명 | 설명 |
|---|---|
| FilePattern | 파일명, 폴더명, 와일드 카드. 상대 패스로 지정했을 경우는, %A_WorkingDir%(으)로부터 검색된다. |
| IncludeFolders? | 「0」(이)라면 파일만을 대상으로 한다. 「1」(이)라면 파일과 폴더를 대상으로 한다. 「2」(이)라면 폴더만을 대상으로 한다. 디폴트는 「0」. |
| Recurse? | 「0」(이)라면 서브 폴더내는 검색하지 않는다. 「1」(이)라면 모든 서브 폴더를 재귀적으로 검색해, 패턴에 매치하는 것을 처리한다. 디폴트는 「0」. |
Remarks
NTFS그럼, 파일은 이름순에 처리된다.
FAT그럼, 처리되는 차례는 부정.
파일의 풀 패스가259문자 이상의 파일은 무시된다.
처리 대상이 되어 있는 파일의 정보는, 이하의 편입 변수로서 참조할 수 있다.
| A_LoopFileName | 파일명(디렉토리 패스를 제외하다) |
| A_LoopFileExt | 파일의 확장자(extension). 「.」(은)는 포함하지 않는다(례:「txt」) |
| A_LoopFileFullPath | 파일의 풀 패스. 다만,FilePattern그리고 상대 패스를 지정했을 경우는, 이쪽도 상대 패스가 된다. |
| A_LoopFileLongPath | 롱 파일 네임 형식의, 정식적 풀 패스. |
| A_LoopFileShortPath | 파일의8.3형식이 짧은 패스. 다만,FilePattern그리고 상대 패스를 지정했을 경우는, 이쪽도 상대 패스가 된다. NTFS그리고 숏패스의 생성을 무효로 하고 있는 경우, 이 변수는 비운다. |
| A_LoopFileShortName | 8.3형식의 쇼트 파일 네임. NTFS의 쇼트 파일 네임 생성이 무효가 되어 있는 등의 이유에 의해 취득에 실패했을 경우는,A_LoopFileName(와)과 같은 것이 된다. |
| A_LoopFileDir | 파일이 있는 디렉토리. 다만,FilePattern그리고 상대 패스를 지정했을 경우는, 이쪽도 상대 패스가 된다. |
| A_LoopFileTimeModified | 파일의 최종 갱신 일시. YYYYMMDDHH24MISS형식. |
| A_LoopFileTimeCreated | 파일이 만들어진 일시. YYYYMMDDHH24MISS형식. |
| A_LoopFileTimeAccessed | 파일의 최종 액세스 일시. YYYYMMDDHH24MISS형식. |
| A_LoopFileAttrib | 파일의 속성. FileGetAttrib그리고 취득되는 것과 같다. |
| A_LoopFileSize | 파일 사이즈(Byte단위).4기가바이트 이상의 사이즈에도 대응. |
| A_LoopFileSizeKB | 파일의 사이즈(KB단위) |
| A_LoopFileSizeMB | 파일의 사이즈(MB단위) |
그 외의 사양은, 통상의 Loop(와)과 같이.
Related
Loop, Break, Continue, Blocks, FileSetAttrib, FileSetTime
Example(s)
; Example #1:
Loop, %ProgramFiles%\*.txt, , 1 ; Recurse into subfolders.
{
MsgBox, 4, , Filename = %A_LoopFileFullPath%`n`nContinue?
IfMsgBox, No
break
}
; Example #2: Calculate the size of a folder, including the files in all its subfolders: SetBatchLines, -1 ; Make the operation run at maximum speed. FolderSizeKB = 0 FileSelectFolder, WhichFolder Loop, %WhichFolder%\*.*, , 1 FolderSizeKB += %A_LoopFileSizeKB% MsgBox Size of %WhichFolder% is %FolderSizeKB% KB.
; Example #3: Retrieve file names sorted by name (see next example to sort by date):
FileList = ; Initialize to be blank.
Loop, C:\*.*
FileList = %FileList%%A_LoopFileName%`n
Sort, FileList, R ; The R option sorts in reverse order. See Sort for other options.
Loop, parse, FileList, `n
{
if A_LoopField = ; Ignore the blank item at the end of the list.
continue
MsgBox, 4,, File number %A_Index% is %A_LoopField%. Continue?
IfMsgBox, No
break
}
; Example #4: Retrieve file names sorted by modification date:
FileList =
Loop, %UserProfile%\Recent\*.*, 1 ; UserProfile exists as an environment variable on some OSes.
FileList = %FileList%%A_LoopFileTimeModified%`t%A_LoopFileName%`n
Sort, FileList ; Sort by date.
Loop, parse, FileList, `n
{
if A_LoopField = ; Omit the last linefeed (blank item) at the end of the list.
continue
StringSplit, FileItem, A_LoopField, %A_Tab% ; Split into two parts at the tab char.
MsgBox, 4,, The next file (modified at %FileItem1%) is:`n%FileItem2%`n`nContinue?
IfMsgBox, No
break
}
; Example #5: Copy only the source files that are newer than their counterparts
; in the destination:
CopyIfNewer:
; Caller has set the variables CopySourcePattern and CopyDest for us.
Loop, %CopySourcePattern%
{
copy_it = n
IfNotExist, %CopyDest%\%A_LoopFileName% ; Always copy if target file doesn't yet exist.
copy_it = y
else
{
FileGetTime, time, %CopyDest%\%A_LoopFileName%
EnvSub, time, %A_LoopFileTimeModified%, seconds ; Subtract the source file's time from the destination's.
if time < 0 ; Source file is newer than destination file.
copy_it = y
}
if copy_it = y
{
FileCopy, %A_LoopFileFullPath%, %CopyDest%\%A_LoopFileName%, 1 ; Copy with overwrite=yes
if ErrorLevel <> 0
MsgBox, Could not copy "%A_LoopFileFullPath%" to "%CopyDest%\%A_LoopFileName%".
}
}
Return
; Example #6: Convert filenames passed in via command-line parameters to long names,
; complete path, and correct uppercase/lowercase characters as stored in the file system.
; This script requires v1.0.25+.
Loop %0% ; For each file dropped onto the script (or passed as a parameter).
{
GivenPath := %A_Index% ; Retrieve the next command line parameter.
Loop %GivenPath%
LongPath = %A_LoopFileLongPath%
MsgBox The case-corrected long path name of file`n%GivenPath%`nis:`n%LongPath%
}반응형
'AUTOHOTKEY > 레퍼런스' 카테고리의 다른 글
| Loop,READ 텍스트 파일을1행씩 읽어들여, 반복 처리를 실시한다 (0) | 2007.11.05 |
|---|---|
| Loop,PARSE 문자열을 지정의 단락 문자로 분할하고, 각각 대해 반복 처리 (0) | 2007.11.05 |
| Loop 커멘드 혹은 블록을 지정 회수 혹은break등이 실행될 때까지 반복한다 (0) | 2007.11.05 |
| Log() 주어진 수치의 상용대수(10(을)를 바닥으로 한 대수)(을)를 돌려주는 함수 (0) | 2007.11.05 |
| Ln() 주어진 수치의 자연대수(네피아수e(을)를 바닥으로 한 대수)(을)를 돌려주는 함수 (0) | 2007.11.05 |
Comments