파일에 텍스트를 덧붙임.
파일 복사
폴더와 폴더 內 파일 전부 복사
폴더 새로만들기
링크파일 만들기
파일 삭제
컴파일된 스크립트에 지정 파일을 포함
파일이나 폴더의 속성 알아내기
링크 파일에 대한 정보 알아내기.
파일의 크기 알아내기.
파일이나 폴더의 타임스탬프 정보 가져오기.
파일의 버전정보 가져오기.
파일 이동/이름변경.
폴더 이동/이름변경.
파일 내용 전부 읽어오기
파일의 특정 라인 읽어오기.
파일 지우거나 휴지통으로 보내기.
휴지통 비우기.
폴더 지우기
파일 선택하는 표준 다이얼로그 띄우기
폴더 선택하는 표준 다이얼로그 띄우기
파일/폴더의 속성 바꾸기.
파일, 폴더의 타임스탬프 정보 바꾸기.
23개나 되는 명령어를 한꺼번에 소개할 순 없으니 우선 File과 관련된 가장 기본적인 명령어를 소개합니다.
저는 FileAppend와 FileRead를 주로 사용합니다.
FileAppend 파일에 텍스트를 덧붙이는 것으로 주로 텍스트 파일을 생성해 내거나 편집할 때 사용합니다.
FileAppend [, Text, Filename]
위와 같은 명령어 형태로 사용되어 지며 입력하고자 하는 텍스트와 파일이름을 지정할 수 있습니다.
FileAppend, 안녕, hello.txt
이렇게 명령어를 작성하면, 안녕이라는 글자를 hello.txt.파일에 생성합니다.
만약 텍스트 파일이 없다면 새로 파일을 생성하여 줍니다.
Text에는 변수 또한 활용 할 수 있습니다.
cent = 안녕
FileAppend, %cent%, hello.txt. 이렇게 한다해도 같은 결과 값을 도출 할 수 있습니다.
FileRead, OutputVar, Filename
FileRead 명령어를 통해서 파일안에 텍스트를 불러옵니다.
위의 명령어를 통해서 위에서 생성한 텍스트 파일을 불러온다면 같은 값이 나오겠지요.
FileRead, %pent%, hello.txt
msgbox,%pent%
이렇게 한다면 메시지 박스에 '안녕'이라는 글이 뜨겠지요.
이 두가지의 명령어만 활용하더라도 엄청나게 활용해 볼 수 있습니다.
더보기를 클릭하시면 File관련 명령어 정리를 볼 수 있습니다.
FileAppend
명령어 : FileAppend [, Text, Filename]
설 명 :파일에 텍스트를 덧붙임.
참 고 :
FileAppend, Another line.`n, C:\My Documents\Test.txt The following 예제 uses a continuation section to enhance readability and maintainability: FileAppend, ( A line of text. By default, the hard carriage return (Enter) between the previous line and this one will be written to the file. This line is indented with a tab; by default, that tab will also be written to the file. Variable references such as %Var% are expanded by default. ), C:\My File.txt
FileCopy
명령어 : FileCopy, SourcePattern, DestPattern [, Flag]
설 명 :파일 복사
참 고 :
FileCopy, C:\My Documents\List1.txt, D:\Main Backup\ Make a copy but keep the orig. file name. FileCopy, C:\My File.txt, C:\My File New.txt Copy a file into the same folder by providing a new name. FileCopy, C:\Folder1\*.txt, D:\New Folder\*.bkp Copy to new location and give new extension.
FileCopyDir
명령어 : FileCopyDir, Source, Dest [, Flag]
설 명 :폴더와 폴더 內 파일 전부 복사
참 고 :
FileCopyDir, C:\My Folder, C:\Copy of My Folder 예제 #2: A working script that prompts you to copy a folder. FileSelectFolder, SourceFolder, , 3, Select the folder to copy if SourceFolder = return Otherwise, continue. FileSelectFolder, TargetFolder, , 3, Select the folder IN WHICH to create the duplicate folder. if TargetFolder = return Otherwise, continue. MsgBox, 4, , A copy of the folder "%SourceFolder%" will be put into "%TargetFolder%".Continue? IfMsgBox, No return SplitPath, SourceFolder, SourceFolderName Extract only the folder name from its full path. FileCopyDir, %SourceFolder%, %TargetFolder%\%SourceFolderName% if ErrorLevel MsgBox The folder could not be copied, perhaps because a folder of that name already exists in "%TargetFolder%". return
FileGetSize, size, C:\My Documents\test.doc Retrieve the size in bytes. FileGetSize, size, C:\My Documents\test.doc, K Retrieve the size in Kbytes.
FileGetTime
명령어 : FileGetTime, OutputVar [, Filename, WhichTime]
설 명 :파일이나 폴더의 타임스탬프 정보 가져오기.
참 고 :
FileGetTime, OutputVar, C:\My Documents\test.doc Retrieves the modification time by default. FileGetTime, OutputVar, C:\My Documents\test.doc, C Retrieves the creation time.
명령어 : FileMove, SourcePattern, DestPattern [, Flag]
설 명 :파일 이동/이름변경.
참 고 :
FileMove, C:\My Documents\List1.txt, D:\Main Backup\ Move the file without renaming it. FileMove, C:\File Before.txt, C:\File After.txt Rename a single file. FileMove, C:\Folder1\*.txt, D:\New Folder\*.bkp Move and rename files to a new extension.
FileMoveDir
명령어 : FileMoveDir, Source, Dest [, Flag]
설 명 :폴더 이동/이름변경.
참 고 :
FileMoveDir, C:\My Folder, D:\My Folder Move to a new drive. FileMoveDir, C:\My Folder, C:\My Folder (renamed), 1
FileRead
명령어 : FileRead, OutputVar, Filename
설 명 :파일 내용 전부 읽어오기
참 고 :FileRead, OutputVar, C:\My Documents\My File.txt
FileReadLine
명령어 : FileReadLine, OutputVar, Filename, LineNum
설 명 :파일의 특정 라인 읽어오기.
참 고 :
Loop { FileReadLine, line, C:\My Documents\ContactList.txt, %A_Index% if ErrorLevel break MsgBox, 4, , Line #%A_Index% is "%line%".Continue? IfMsgBox, No return } MsgBox, The end of the file has been reached or there was a problem. return
FileRecycle
명령어 : FileRecycle, FilePattern
설 명 :파일 지우거나 휴지통으로 보내기.
참 고 :FileRecycle, C:\temp files\*.tmp
FileRecycleEmpty
명령어 : FileRecycleEmpty [, DriveLetter]
설 명 :휴지통 비우기.
참 고 :FileRecycleEmpty, C:\
FileRemoveDir
명령어 : FileRemoveDir, DirName [, Recurse?]
설 명 :폴더 지우기
참 고 :FileRemoveDir, C:\Download Temp FileRemoveDir, C:\Download Temp, 1
FileSelectFile
명령어 : FileSelectFile, OutputVar [, Options, RootDir\Filename, Prompt, Filter]
설 명 :파일 선택하는 표준 다이얼로그 띄우기
참 고 :
FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt; *.doc) if SelectedFile = MsgBox, The user didn't select anything. else MsgBox, The user selected the following:`n%SelectedFile% CLSID 예제: FileSelectFile, OutputVar,, ::{645ff040-5081-101b-9f08-00aa002f954e} Recycle Bin. Multi-Select 예제: FileSelectFile, files, M3 M3 = Multiselect existing files. if files = { MsgBox, The user pressed cancel. return } Loop, parse, files, `n { if a_index = 1 MsgBox, The selected files are all contained in %A_LoopField%. else { MsgBox, 4, , The next file is %A_LoopField%.Continue? IfMsgBox, No, break } } return
FileSelectFolder
명령어 : FileSelectFolder, OutputVar [, StartingFolder, Options, Prompt]
설 명 :폴더 선택하는 표준 다이얼로그 띄우기
참 고 :
FileSelectFolder, OutputVar, , 3 if OutputVar = MsgBox, You didn't select a folder. else MsgBox, You selected folder "%OutputVar%". CLSID 예제: FileSelectFolder, OutputVar, ::{20d04fe0-3aea-1069-a2d8-08002b30309d} My Computer.
FileSetAttrib
명령어 : FileSetAttrib, Attributes [, FilePattern, OperateOnFolders?, Recurse?]
설 명 :파일/폴더의 속성 바꾸기.
참 고 :
FileSetAttrib, +RH, C:\MyFiles\*.*, 1 +RH is identical to +R+H FileSetAttrib, ^H, C:\MyFiles Toggle the folder's "hidden" attribute. FileSetAttrib, -R+A, C:\New Text File.txt FileSetAttrib, +A, C:\*.ini, , 1 Recurse through all .ini files on the C drive.
FileSetTime
명령어 : FileSetTime [, YYYYMMDDHH24MISS, FilePattern, WhichTime, OperateOnFolders?, Recurse?]
설 명 :파일, 폴더의 타임스탬프 정보 바꾸기.
참 고 :
Set the modification time to the current time for all matching files: FileSetTime, , C:\temp\*.txt Set the modification date (time will be midnight): FileSetTime, 20040122, C:\My Documents\test.doc Set the creation date. The time will be set to 4:55pm: FileSetTime, 200401221655, C:\My Documents\test.doc, C Change the mod-date of all filesthat match a pattern. Any matching folders will also be changed due to the last parameter: FileSetTime, 20040122165500, C:\Temp\*.*, M, 1