Scripting Runtime Library(FileSystemObject)

ÁöÁ¤ÇÑ ÆÄÀÏÀ̳ª Æú´õ¸¦ ±âÁ¸ À§Ä¡¿¡¼­ ´Ù¸¥ À§Ä¡·Î ¿Å±ä´Ù.

Àμö/ÆĶó¸ÞÅÍ
object
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, Ç×»ó FileÀ̳ª Folder °³Ã¼ÀÇ À̸§ÀÌ´Ù.
destination
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, ÆÄÀÏÀ̳ª Æú´õ¸¦ ¿Å±æ ´ë»óÀÌ´Ù. ¿ÍÀϵåÄ«µå ¹®ÀÚ´Â »ç¿ëÇÒ ¼ö ¾ø´Ù.
¹Ýȯ°ª

¹Ýȯ°ªÀº ¾ø´Ù.

¼³¸í

ÁöÁ¤ÇÑ ÆÄÀÏÀ̳ª Æú´õ¸¦ ±âÁ¸ À§Ä¡¿¡¼­ ´Ù¸¥ À§Ä¡·Î ¿Å±ä´Ù.

FileÀ̳ª Folder¿¡ Move ¸Þ¼­µå¸¦ »ç¿ëÇϸé FileSystemObject.MoveFileÀ̳ª FileSystemObject.MoveFolder¸¦ »ç¿ëÇÑ °á°ú¿Í µ¿ÀÏÇÏ´Ù.
±×·¯³ª ÀÌ·± ´ëü ¸Þ¼­µå¸¦ »ç¿ëÇϸé ÆÄÀÏÀ̳ª Æú´õ¸¦ Çѹø¿¡ ¿©·¯ °³ ¿Å±æ ¼ö ÀÖ´Ù.


Move ¸Þ¼­µå·Î File À̵¿ ¿¹Á¦

°á°ú Ç¥½Ãâ
JScript File Move ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=JScript>
function MoveFileTest(filePath,destination){
  str='';
  var fso=new ActiveXObject('Scripting.FileSystemObject');
  if (!fso.FileExists(filePath)){
    fileObj=fso.OpenTextFile(filePath,2,true);
    fileObj.WriteLine('¿¹Á¦¸¦ À§ÇÑ ÆÄÀÏÀÌ´Ù.');
    fileObj.Close();
    str+='¿øº» ÆÄÀÏÀÌ ¾ø¾î '+filePath+' ÆÄÀÏÀ» »ý¼ºÇÏ¿´´Ù.<BR>';
  }
  if (!fso.FolderExists(destination)){
    fso.CreateFolder(destination);
    str+='º¹»ç Æú´õ°¡ ¾ø¾î '+destination+' Æú´õ¸¦ »ý¼ºÇÏ¿´´Ù.<BR>';
  }
  targetFile=destination+'\\'+fso.GetFileName(filePath);
  if (fso.FileExists(targetFile)){
    fso.DeleteFile(targetFile);
    str+='º¹»ç ÆÄÀÏÀÌ ÀÖ¾î '+targetFile+' ÆÄÀÏÀ» »èÁ¦ÇÏ¿´´Ù.<BR>';
  }

  fileObj=fso.GetFile(filePath);
  fileObj.Move(destination);
  str+='¿øº» '+filePath+' ÆÄÀÏÀ» '+destination+'À¸·Î À̵¿ÇÏ¿´´Ù.';
  return(str);
}
</SCRIPT>

<DIV id=showFilejs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show onClick="id=showFilejs.innerHTML=
  MoveFileTest('C:\\JsTest\\CreateText.txt','C:\\JsTest\\MoveTest\\')">
  <SPAN class=ie>JScript</SPAN> File <SPAN class=method>Move</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>
¿¹Á¦</DIV>
°á°ú Ç¥½Ãâ
VBScript File Move ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=VBScript>
Function MoveFileTestvb(filePath,destination)
  Dim fso,targetFile
  str=""
  Set fso=CreateObject("Scripting.FileSystemObject")
  If Not fso.FolderExists(folderPath) Then
    Set fileObj=fso.OpenTextFile(filePath,2,True)
    fileObj.WriteLine "¿¹Á¦¸¦ À§ÇÑ ÆÄÀÏÀÌ´Ù."
    fileObj.Close
    str=str&"¿øº» ÆÄÀÏÀÌ ¾ø¾î "&filePath&" ÆÄÀÏÀ» »ý¼ºÇÏ¿´´Ù.<BR>"
  End If

  If Not fso.FolderExists(destination) Then
    fso.CreateFolder(destination)
    str=str&"º¹»ç Æú´õ°¡ ¾ø¾î "&destination&" Æú´õ¸¦ »ý¼ºÇÏ¿´´Ù.<BR>"
  End If

  targetFile=destination&"\"&fso.GetFileName(filePath)
  If fso.FileExists(targetFile) Then
    fso.DeleteFile(targetFile)
    str=str&"º¹»ç ÆÄÀÏÀÌ ÀÖ¾î "&targetFile&" ÆÄÀÏÀ» »èÁ¦ÇÏ¿´´Ù.<BR>"
  End If

  Set fileObj=fso.GetFile(filePath)
  fileObj.Move(destination)
  str=str&"¿øº» "&filePath&" ÆÄÀÏÀ» "&destination&"À¸·Î À̵¿ÇÏ¿´´Ù."

  MoveFileTestvb=str
End Function
</SCRIPT>

<DIV id=showFilevb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show onClick="showFilevb.innerHTML=
MoveFileTestvb('C:\\JsTest\\CreateText.txt','C:\\JsTest\\MoveTest\\')">
  <SPAN class=ie>VBScript</SPAN> File <SPAN class=method>Move</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>

Move ¸Þ¼­µå·Î Folder À̵¿ ¿¹Á¦

°á°ú Ç¥½Ãâ
JScript Folder Move ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=JScript>
function MoveFolderTest(folderPath,destination){
  str='';
  var fso=new ActiveXObject('Scripting.FileSystemObject');
  if (!fso.FolderExists(folderPath)){
    fso.CreateFolder(folderPath);
    str+='¿øº» Æú´õ°¡¾ø¾î '+folderPath+' Æú´õ¸¦ »ý¼ºÇÏ¿´´Ù.<BR>';
  }
  if (fso.FolderExists(destination)){
    fso.DeleteFolder(destination);
    str+='º¹»ç Æú´õ°¡ ÀÖ¾î '+destination+' Æú´õ¸¦ »èÁ¦ÇÏ¿´´Ù.<BR>';
  }

  folderObj=fso.GetFolder(folderPath);
  folderObj.Move(destination);
  str+='¿øº» '+folderPath+' Æú´õ¸¦ '+destination+'À¸·Î À̵¿ÇÏ¿´´Ù.';
  return(str);
}
</SCRIPT>

<DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show onClick="id=showjs.innerHTML=
  MoveFolderTest('C:\\JsTest\\MoveTest','C:\\JsTest\\MoveTarget')">
  <SPAN class=ie>JScript</SPAN> Folder <SPAN class=method>Move</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>
°á°ú Ç¥½Ãâ
VBScript Folder Move ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=VBScript>
Function MoveTestvb(folderPath,destination)
  Dim fso,targetFile
  str=""
  Set fso=CreateObject("Scripting.FileSystemObject")
  If Not fso.FolderExists(folderPath) Then
    fso.CreateFolder(folderPath)
    str=str&"¿øº» Æú´õ°¡ ¾ø¾î "&folderPath&" Æú´õ¸¦ »ý¼ºÇÏ¿´´Ù.<BR>"
  End If

  If fso.FolderExists(destination) Then
    fso.DeleteFolder(destination)
    str=str&"º¹»ç Æú´õ°¡ ÀÖ¾î "&destination&" Æú´õ¸¦ »èÁ¦ÇÏ¿´´Ù.<BR>"
  End If

  Set folderObj=fso.GetFolder(folderPath)
  folderObj.Move(destination)
  str=str&"¿øº» "&folderPath&" Æú´õ¸¦ "&destination&"À¸·Î À̵¿ÇÏ¿´´Ù."
  MoveTestvb=str
End Function
</SCRIPT>

<DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show onClick="showvb.innerHTML=
  MoveTestvb('C:\\JsTest\\MoveTest','C:\\JsTest\\MoveTarget')">
  <SPAN class=ie>VBScript</SPAN> Folder <SPAN class=method>Move</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>