列出一些IDL中常用的文件操作函数命令。
- FILE_MKDIR . 语法:FILE_MKDIR, File1 [,… FileN]
创建给定目录。若省略绝对路径,则在当前路径下创建。
compile_opt idl2
File_counts = 2
Dest_Dir = 'D:\LG Files\Code\'
CD, Dest_Dir
For num = 1, File_counts Do Begin
FILE_MKDIR, '文件夹创建测试 ' + strtrim(string(num),2) + ' 文件操作命令'
; strtrim()去除字符串中的空格, 参看文档。
EndFor
Print, 'End of Procedure!'
End
- FILE_COPY . 语法:FILE_COPY, SourcePath, DestPath [, /OVERWRITE]
语句中的其他关键字详见帮助手册。
Rename the file backup.dat to primary.dat in the current working directory:
**FILE_MOVE, 'backup.dat', 'primary.dat'**
Create a subdirectory named BACKUP in the current working directory and move all .pro files, makefile, and mydata.dat into it:
**FILE_MKDIR, 'BACKUP'
FILE_MOVE, ['*.pro', 'makefile', 'mydata.dat'], 'BACKUP'**
- FILE_DELETE. 语法:FILE_DELETE, File1[,… Filen]
The FILE_DELETE procedure deletes a file or empty directory。 - FILE_DIRNAME. Returns the dirname of a file path。
语法:Result = FILE_DIRNAME(Path [, /MARK_DIRECTORY])
关键字的效果如下:
ENVI> print, FILE_DIRNAME('D:\LG Files\Code\temp.xls')
D:\LG Files\Code
ENVI> print, FILE_DIRNAME('D:\LG Files\Code\temp.xls',/MARK_DIRECTORY)
D:\LG Files\Code\
-
FILE_GUNZIP. Uncompresses a given GZIP input file or files, and saves the uncompressed data into a new file.
语法:FILE_GUNZIP, File [, FileOut] [, /DELETE] ,[/VERBOSE] -
FILE_GZIP. Compresses a given input file (or files) using the DEFLATE compression algorithm, and saves the resulting compressed data in the GZIP file format into a new file or to memory.
语法:FILE_GZIP, File [, FileOut] [, /DELETE],[/VERBOSE] -
FILE_ZIP. compresses a given set of input files and directories into the PKWARE ZIP file format, using the DEFLATE compression algorithm for all files within the ZIP.
语法:FILE_ZIP, Files [, FileOut] [, /VERBOSE] -
FILE_UNZIP. Uncompresses ZIP files.
语法:FILE_UNZIP, File [, DirectoryOut] [, /VERBOSE]