X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 17 Nov 2008 02:32 AM by  anon
Renaming file
 0 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
17 Nov 2008 02:32 AM
    I want to rename some files that I have created using the following code. *************** PRO MoveFile   strFileOld = ["test1.nc", "test2.nc"]   strFileNew = ["test3.nc", "test4.nc"]   strFileNewName = ["test5.nc", "test6.nc"]     FOR iFile = 0, 1 DO BEGIN     lngNcdfIDOld = NCDF_OPEN(strFileOld(iFile))     lngNcdfIDNew = NCDF_CREATE(strFileNew(iFile), /CLOBBER)     result = NCDF_ATTCOPY(lngNcdfIDOld, 'history', lngNcdfIDNew, /IN_GLOBAL, /OUT_GLOBAL)     NCDF_CLOSE, lngNcdfIDOld     NCDF_CLOSE, lngNcdfIDNew   ENDFOR     FOR iFile = 0, 1 DO BEGIN     FILE_MOVE, strFileNew(iFile), strFileNewName(iFile), /OVERWRITE, /VERBOSE   ENDFOR *********** Unfortunately, I received an error message of: "Unable to rename file: Source  File: \test1.nc, Destination  File: \test3.nc The process cannot access the file because it is being used by another process. " I thought that by closing the files, the system should have regained access.  I did try the following code, that dealt with text file and it works. *********   strFileOld = ["test1.txt", "test2.txt"]   strFileNew = ["test3.txt", "test4.txt"]   strFileNewName = ["test5.txt", "test6.txt"]     FOR iFile = 0, 1 DO BEGIN     OPENR, lngUnitOld, strFileOld(iFile), /GET_LUN     READF, lngUnitOld, intVar     OPENW, lngUnitNew, strFileNew(iFile), /GET_LUN     PRINTF, lngUnitNew, intVar     CLOSE, lngUnitOld     CLOSE, lngUnitNew   ENDFOR     FOR iFile = 0, 1 DO BEGIN     FILE_MOVE, strFileOld(iFile), strFileNewName(iFile), /OVERWRITE, /VERBOSE   ENDFOR ********** So, I don't quite understand what NCDF_CLOSE does. Many thanks for your help.
    You are not authorized to post a reply.