AUTOHOTKEY/레퍼런스
FileCopy 파일을 카피한다
님투
2007. 11. 5. 13:07
반응형
FileCopy
파일을 카피한다
FileCopy, SourcePattern, DestPattern [, Flag]
Parameters
인수명 | 설명 |
---|---|
SourcePattern | 파일명 혹은 와일드 카드. 상대 패스로 지정했을 경우는, %A_WorkingDir%(을)를 기준으로 한 패스가 된다. |
DestPattern | 카피 후의 파일명 혹은 와일드 카드. 상대 패스로 지정했을 경우는, %A_WorkingDir%(을)를 기준으로 한 패스가 된다. |
Flag | 「1」(을)를 지정하면, 동명의 파일이 존재했을 때에 덧쓰기를 실시한다. 생략시나 「0」(을)를 지정했을 경우는, 동명의 파일이 존재했을 때는 카피하지 않는다. |
ErrorLevel
카피에 실패한 파일의 수가 된다
Remarks
카피중에 에러가 발생해도, 처리는 속행된다
파일을 그 파일 자신에게 덧쓰기 카피하려고 했을 경우, 에러로 간주해진다.
서브 폴더를 포함 폴더내의 파일을 모두 카피하려면 , FileCopyDir(을)를 사용한다.
Related
FileMove, FileCopyDir, FileMoveDir, FileDelete
Example(s)
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.
; The following example copies all files and folders inside a folder to a different folder: ErrorCount := CopyFilesAndFolders("C:\My Folder\*.*", "D:\Folder to receive all files & folders") if ErrorCount <> 0 MsgBox %ErrorCount% files/folders could not be copied. CopyFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = false) ; Copies all files and folders matching SourcePattern into the folder named DestinationFolder and ; returns the number of files/folders that could not be copied. { ; First copy all the files (but not the folders): FileCopy, %SourcePattern%, %DestinationFolder%, %DoOverwrite% ErrorCount := ErrorLevel ; Now copy all the folders: Loop, %SourcePattern%, 2 ; 2 means "retrieve folders only". { FileCopyDir, %A_LoopFileFullPath%, %DestinationFolder%\%A_LoopFileName%, %DoOverwrite% ErrorCount += ErrorLevel if ErrorLevel ; Report each problem folder by name. MsgBox Could not copy %A_LoopFileFullPath% into %DestinationFolder%. } return ErrorCount }
반응형