?
Solved

Moving files script

Posted on 2007-03-19
8
Medium Priority
?
469 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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