ÁöÁ¤ÇÑ ÆÄÀÏÀ̳ª Æú´õÀÇ À̸§À» ¼³Á¤Çϰųª ¹ÝȯÇÑ´Ù.
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, FileÀ̳ª Folder °³Ã¼ÀÇ À̸§ÀÌ´Ù.
»õ·Î¿î À̸§À» ÁöÁ¤Çϸé À̸§¹Ù²Ù±â(rename)¿¡ ÇØ´çµÈ´Ù.
À̸§À» ¹Ù²Ù¸é ¿ø·¡ÀÇ À̸§¿¡ ÇØ´çÇÏ´Â °³Ã¼´Â ¾ø¾îÁö°í »õ·Î¿î À̸§ÀÇ °³Ã¼°¡ »ý¼ºµÈ´Ù.
ÀÌ ¼Ó¼ºÀº Àбâ/¾²±âÀÌ¸ç µðÆúÆ®°ªÀº ¾ø´Ù.
<SCRIPT language=JScript> function NameTest(filePath){ var fso,fileObj,str; fso=new ActiveXObject('Scripting.FileSystemObject'); if (!fso.FileExists(filePath)){ // ¿À·ù ¹æÁö¸¦ À§ÇÏ¿© ¿øº» ÈÀÏÀÌ ¾øÀ¸¸é »ý¼ºÇÑ´Ù. fileObj=fso.OpenTextFile(filePath,2,true); fileObj.Write(filePath+' ÈÀÏ'); fileObj.Close(); } newPath='c:\\JsTest\\NewName.txt'; if (fso.FileExists(newPath)){ // ¿À·ù ¹æÁö¸¦ À§ÇÏ¿© »õ·Î ÁöÁ¤ÇÒ ÈÀÏÀÌ ÀÖÀ¸¸é »èÁ¦ÇÑ´Ù. newObj=fso.GetFile(newPath); newObj.Delete(); } fileObj=fso.GetFile(filePath) str='fileObj.Name='+fileObj.Name+'<BR>'; oldName=fileObj.Name; folderObj=fso.GetFolder(fileObj.ParentFolder); str+='folderObj.Name='+folderObj.Name+'<BR>'; fileObj.Name='NewName.txt'; str+=oldName+'°¡ '+fileObj.Name+'À¸·Î º¯°æµÇ¾ú´Ù.<BR>'; str+='fileObj.Name='+fileObj.Name+'<BR><BR>'; str+='fileObj.Attributes='+fileObj.attributes+'<BR>'; if (fileObj.attributes&&32){ fileObj.attributes=fileObj.attributes-32; str+='Archive ºñÆ®¸¦ Áö¿ü´Ù.'; } else { fileObj.attributes=fileObj.attributes+32; str+='Archive ºñÆ®¸¦ ¼³Á¤Çß´Ù.'; } return(str); } </SCRIPT> <DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="showjs.innerHTML=NameTest('C:\\JsTest\\expSample.txt')"> <SPAN class=ie>JScript</SPAN> <SPAN class=property>Name</SPAN> ¼Ó¼º ¿¹Á¦</DIV>
<SCRIPT language=VBScript> Function NameTestvb(filePath) Dim fso,fileObj,newPath,newObj Set fso=CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(filePath) Then ' ¿À·ù ¹æÁö¸¦ À§ÇÏ¿© ¿øº» ÈÀÏÀÌ ¾øÀ¸¸é »ý¼ºÇÑ´Ù. Set fileObj=fso.OpenTextFile(filePath,2,true) fileObj.Write filePath&" ÈÀÏ" fileObj.Close End If newPath="c:\JsTest\NewName.txt" If fso.FileExists(newPath) Then ' ¿À·ù ¹æÁö¸¦ À§ÇÏ¿© »õ·Î ÁöÁ¤ÇÒ ÈÀÏÀÌ ÀÖÀ¸¸é »èÁ¦ÇÑ´Ù. Set newObj=fso.GetFile(newPath) newObj.Delete End If Set fileObj=fso.GetFile(filePath) Set folderObj=fso.GetFolder(fileObj.ParentFolder) str="fileObj.Name="&fileObj.Name&"<BR>" oldName=fileObj.Name str=str&"folderObj.Name="&folderObj.Name&"<BR>" fileObj.Name="NewName.txt" str=str&oldName&"°¡ "&fileObj.Name&"À¸·Î º¯°æµÇ¾ú´Ù.<BR>" str=str&"fileObj.Name="&fileObj.Name&"<BR><BR>" str=str&"fileObj.Attributes="&fileObj.attributes&"<BR>" if fileObj.attributes and 32 Then fileObj.attributes=fileObj.attributes-32 str=str&"Archive ºñÆ®¸¦ Áö¿ü´Ù." Else fileObj.attributes=fileObj.attributes+32 str=str&"Archive ºñÆ®¸¦ ¼³Á¤Çß´Ù." End If NameTestvb=str End Function </SCRIPT> <DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="showvb.innerHTML=NameTestvb('C:\\JsTest\\expSample.txt')"> <SPAN class=ie>VBScript</SPAN> <SPAN class=property>Name</SPAN> ¼Ó¼º ¿¹Á¦</DIV>