Solved

Moving files script

Posted on 2007-03-19
8
468 Views
Last Modified: 2008-01-09
Hi i would like to create a vbs script or a batch file that can be deployed using a gpo for computers.
I would like to move files from C:\Gallery Data Files\ to C:\Program Files\SMART Board Software\Gallery.
The only file extentions i want to move are .galleryitem, .notebook and xml files. i have written a basic batch file but it does not execute via a GPo but does when you are it manaully,
the batch file i have is below and it is deployed via a gpo using a computer startup.
cd\
move /y "C:\Gallery Data Files\*.galleryitem" "C:\Program Files\SMART Board Software\Gallery"
move /y "C:\Gallery Data Files\*.notebook" "C:\Program Files\SMART Board Software\Gallery"
move /y "C:\Gallery Data Files\*.xml" "C:\Program Files\SMART Board Software\Gallery"

hope u can help

Andrew
0
Comment
Question by:habsboys
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18748939
Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim objFolder=objFSO.GetFolder("C:\Gallery Data Files\")

For each file in objFolder.Files
  strExt=objFSO.GetExtensionName
  If strExt="galleryitem" or strExt= "notebook" or strExt="xml" Then
    objFSO.Move file.path, "C:\Program Files\SMART Board Software\Gallery\"
  End If
Next


Or you can simply use
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\Gallery Data Files\*.galleryitem" , "C:\Program Files\SMART Board Software\Gallery\"
objFSO.MoveFile "C:\Gallery Data Files\*.notebook" , "C:\Program Files\SMART Board Software\Gallery\"
objFSO.MoveFile "C:\Gallery Data Files\*.xml" , "C:\Program Files\SMART Board Software\Gallery\"
0
 

Author Comment

by:habsboys
ID: 18754906
Thanks for that

it works however there is an error when  an identical file exists in the destination folder or if the there is no files to move.

I would like it to move the files and overwrite the destination ones without been prompted and if there are no files to move just close with no error.

Andrew
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18755380
Try this...

Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim objFolder=objFSO.GetFolder("C:\Gallery Data Files\")
strTarget="C:\Program Files\SMART Board Software\Gallery\"
For each file in objFolder.Files
  strExt=objFSO.GetExtensionName
  If strExt="galleryitem" or strExt= "notebook" or strExt="xml" Then
    If objFSO.FileExists (strTarget & file.name) Then
      objFSO.CopyFile file.path, strTarget, True
      objFSO.DeleteFile file.path
    Else
      objFSO.Move file.path, strTarget
    End If
  End If
Next
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:habsboys
ID: 18755744
Hi

I get the following error:
Script:......
line: 2
Char: 14
Error: Expected end of statement
Code: 800A0401

Andrew
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18755754
My mistake...change it to this:

Dim objFolder:Set objFolder=objFSO.GetFolder("C:\Gallery Data Files\")
0
 

Author Comment

by:habsboys
ID: 18755805
I get another error

Line : 5
Char:3
Error: wronh number of arguments or invalid property assigngment "GetExtensionName!

Andrew
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18755862
strExt=objFSO.GetExtensionName
should have read

strExt=objFSO.GetExtensionName(file.name)
0
 

Author Comment

by:habsboys
ID: 18755937
Cheers

Worked like a dream.

Thanks for your help
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question