Windows Scripting to copy files

Hi there,
New to Windows scripting. 
I have tried to create a simple script to copy file but failed. Most probably the syntax is wrong. Pls help. thanks.
I give you my code below:
@ECHO OFF
SETLOCAL
REM SET INDIR="\\sge-fs01\enablers_development\ptc\OUTGOING"
SET SLIFTCMD="C:\Program Files\PrivyLink\SLIFT-Ez Classic\1.4\SLIFTC.exe"
SET PFX="C:\PrivyLink\KeyPeer\111111.pfx"
SET PFXPWD="pass12345"
SET CER="C:\PrivyLink\KeyPeer\sgesftpuser.cer"
SET PATTERN="*.IN"
SET DSTDIR="C:\SFTP\OUTBOUND"
SET BKDIR="C:\SFTP\BACKUP"
SET SENDDIR="C:\SFTP\SENDTO"
SET INDIR="C:\SFTP\PTC\OUTGOING"
REM ####### MAIN CALL #########
CALL:MainScript
GOTO :EOF
REM ####### Check Files in PTC OUTGOING #########
:MainScript
SETLOCAL
@ECHO OFF
PUSHD %INDIR%
IF EXIST "C:\SFTP\PTC\OUTGOING\*.IN"
COPY "C:\SFTP\PTC\OUTGOING\*.IN" %DSTDIR%
ELSE 
echo "There are no files today - %date:~-4,4%%date:~-7,2%%date:~-10,2%" >> C:\SFTP\PTC.log
pushd %~dp0
start "" cmd /c cscript SMTP.vbs
POPD
ENDLOCAL
GOTO :EOF
REM ####  END ########

I tried myself and it works now. 
EXISTS can use wildcard (no problem with that). Just that my brackets were not in right position.
They should be like this:
IF EXIST "C:\SFTP\PTC\OUTGOING\*.IN" (   
                                COPY %INDIR%"\*.IN" %DSTDIR%
                                REM COPY "C:\SFTP\PTC\OUTGOING\*.IN" %DSTDIR%
                                REM CALL :ENCRYPT
                ) ELSE (
                                echo "There are no files today - %date:~-4,4%%date:~-7,2%%date:~-10,2%" >> C:\SFTP\PTC.log
                                pushd %~dp0
                                start "" cmd /c cscript SMTP.vbs

Similar Messages

  • Logon Scripts for copying files in Windows 7

    Issues using Logon scripts to copy files in windows 7.  Its default is to append the file rather than copy and replace, which is what XP did.  How can I achieve the same results using
    logon scripts in W7 to copy any files to specified folders and replacing old files.  The reason for this is that we use a software that performs offsite/onsite updates and the only way all the users can have the correct version/tables is to either manually
    update each user in a 90+ user environment or use a logon script to perform the coping of the updates.  Unfortunately the software support won’t create a (while logging in to software) patch for this.  So we have to force it during the user logon.

    Hi Novice,
    It should depend on your script content. it's recommended you ask in the official scripting guys forum for professional help:
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
    Karen Hu
    TechNet Community Support

  • Script for copying files to drop boxes of other Macs

    I don't know much about scripts as yet, but for daily backup purposes
    I would like to copy all new or modified files from various folders
    to the drop boxes of two other Macs (like the old DOS command XCopy)
    and then reset the "modified attributes" (is there something like that at all?)
    of these files.
    A script could do this without the need to always find and select these files
    and to always confirm the messages "You can put items into “Drop Box”,
    but you won’t be able to see them. Do you want to continue?".
    Thanks!

    Here is a short skeleton which doesn't treat subfolders.
    May you check if it do what you want ?
    property sourceFolder : "/Users/home/Documents/Pages/current/"
    property destFolder : "/cr1’s iMac.afpovertcp.tcp.local/cr1's%20Public%20Folder/Drop Box/backup/Documents/Pages/current/"
    on run
    tell application "System Events"
    set dest_folder to path of folder destFolder
    set listeSource to path of disk items of folder sourceFolder
    repeat with sf in listeSource
    if visible of disk item sf then
    tell disk item sf
    set sn to name
    set smd to modification date
    end tell
    if exists disk item sn of folder destFolder then
    set needCopy to modification date of disk item sn of folder destFolder is not smd
    else
    make new file at end of folder destFolder with properties {name:sn}
    set needCopy to true
    end if -- exists disk item
    if needCopy then my copyFile(sf, dest_folder)
    end if -- visible …
    end repeat
    end tell -- System Events
    end run
    on copyFile(sourceFile, targetFolder) (*
    sourceFile is the path to the source file as text,
    dest_folder is the path to the destination folder as text
    newFileName is the name of the file as text
    tell application "Finder"
    duplicate file sourceFile to folder targetFolder with replacing
    end tell
    end copyFile
    Yvan KOENIG (VALLAURIS, France) mercredi 16 décembre 2009 18:33:43

  • Powershell- FTP Script to copy files only after a certain time

    Hey guys,
    We are currently running an FTP script that decrypts pgp and copies/moves several files to different archived and production locations. These files come in constantly throughout the day and we need to ensure a certain 8 files get moved to 4 different locations
    but NOT before a certain time.
    Ex: File1 and File2 are received EARLY along with 50 other files and decrypted at 9pm EST on 9/4. File1 and file2 need to WAIT to be moved until after 12:05am EST on 9/5 or it is slapped with an incorrect $date/time and not processed correctly but
    every other file needs to be moved (which is currently all configured).
    Right now, both file1 and file2 are being moved as the script runs  (every 10 minutes) so when the files come in early from the vendor- they get the incorrect date/time stamp.
    I'm fairly new to powershell so I'm not quite sure how to set this up to only move the file if it is between a certain time- say 12am-1am and no other time.

    I was able to resolve this myself by doing the following:
    $hourdate = get-time –uformat “%H” 
    #Copy-Item as long as time is in the 12:00am or 1am hour 
    if(($hourDate -eq "0")-or ($hourdate -eq "1")) 
    copy-item objects
    Thanks guys

  • Script to copy files when connecting camera?

    Being ever increasingly worried about losing data, especially photos/movies of our family etc, I'd like to have some sort of script/automated process so that when I connect my camera (Canon 400D) - my iMac grabs a copy of the original images from the device and transfers(copies) them to an external drive, or if this is not possible, at least to another location.
    Is this possible, and any ideas on the best/easiest way to acheive this?
    Thanks.
    FWIW - I have multiple usb drives connected, some direct into the iMac, one into my Time Capsule, and also access to my RAID NAS drive - which is where I would prefer to store them, as it offers the most secure medium to backup to.

    You can use Automator to create a folder action that would import the image files into iPhoto and then copy them to a destination folder. You would, however, have to have to use Image Capture or a card reader to upload the files from the camera to the folder.
    Actually, Larry's suggestion of keeping a current, i.e. daily, backup of your iPhoto LIbrary on another drive with a backup application like Synk Standard is the very best route to go. AND never let iPhoto delete the photos from the camera. Always reformat the card using the camera.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier versions) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. There are versions that are compatible with iPhoto 5, 6, 7 and 8 libraries and Tiger and Leopard. Just put the application in the Dock and click on it whenever you want to backup the dB file. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    NOTE: The new rebuild option in iPhoto 09 (v. 8.0.2), Rebuild the iPhoto Library Database from automatic backup" makes this tip obsolete.

  • Best way to run script to copy files on login

    I ran the following script last year for the purpoase of copying shortcuts (ex. college webmail, helpdesk, website) to the desktop. I had the shortcuts in a folder on an open share and on login the script would run and copy the shortcuts.
    #bin/bash
    mkdir /Volumes/scripts
    mount -t afp afp://server/scripts /Volumes/scripts
    cp -R /Volumes/scripts/desktop_shortcuts/* ~/Desktop
    umount /Volumes/scripts
    killall Terminal
    This allowed me to add or adjust shortcuts so we would never need to handle adding these manually in the image or after lab deployment. Last year I added it to the "Login Itmes" for the user but this year I'd like to have it run from a server. I've had no luck getting this to wrok from a WGM Server or Profile Manager Server. I tried the "Login Hooks" from the serverside and no luck.
    I can't seem to find a clear document that tells me what the proper scripting procedure is for Mavericks.
    Some posts say used launchd, some say .plist & others applescript.

    I ran the following script last year for the purpoase of copying shortcuts (ex. college webmail, helpdesk, website) to the desktop. I had the shortcuts in a folder on an open share and on login the script would run and copy the shortcuts.
    #bin/bash
    mkdir /Volumes/scripts
    mount -t afp afp://server/scripts /Volumes/scripts
    cp -R /Volumes/scripts/desktop_shortcuts/* ~/Desktop
    umount /Volumes/scripts
    killall Terminal
    This allowed me to add or adjust shortcuts so we would never need to handle adding these manually in the image or after lab deployment. Last year I added it to the "Login Itmes" for the user but this year I'd like to have it run from a server. I've had no luck getting this to wrok from a WGM Server or Profile Manager Server. I tried the "Login Hooks" from the serverside and no luck.
    I can't seem to find a clear document that tells me what the proper scripting procedure is for Mavericks.
    Some posts say used launchd, some say .plist & others applescript.

  • Windows 8.1 Network Share 0x8007003b Error Copying Files

    Hi All,
    I'm having an issue when copying files from a Windows network share. If the file is above 5MB it will start copying and then after a minute or two I will get an error such as:
    Interrupted Action
    An unexpected error is keeping you from copying the file. If you continue to receive this error, you can use the error code to search for help with this problem.
    Error 0x8007003B: An unexpected network error occurred.
    The network share is in a different office and is accessible over a point-to-point VPN, so the connection is not that fast. 
    But before everyone tells me to start diagnosing the router and or VPN please take note of the following:
    My colleague who is running Windows 7 can copy files from the network share fine
    If I run a Windows 7 VM on my Windows 8.1 laptop I can copy the files across fine
    I also know it isn't an issue with this particular file share. I set up a little lab, where I had one VM which had a shared folder and 2 other client VMs one running Windows 7 and one running Windows 8.1. I limited the bandwidth to the two client
    VMs to a similar speed we see across our VPN. The result was that the Windows 8.1 failed with the same error above, whereas the Windows 7 copied fine.
    There is also a noticeable difference visually when copying using Windows 8.1 and Windows 7:
    Windows 7 - The progress bar progresses smoothly giving the current speed and estimated time remaining
    Windows 8.1 - The progress bar progresses in a jumpy fashion. E.g. it shows no progress, then after a minute it jumps and shows 16% progress, then shows no further progress, then jumps by another 18%. There is no estimated time remaining.
    I ran Wireshark to investigate what was going on at the network layer. I see the following behaviour:
    Windows 8.1 - The file is copying fine then all of a sudden there are a lot of TCP dupack packets. After which the Windows 8.1 client sends a RST packet and then the error pops up.
    Windows 7 - The file is copying fine then you also see a load of TCP dupack packets, however no error is displayed and it continues copying fine.
    I'd appreciate any help with this I'm hoping there are some settings I can change to make Windows 8.1 behave more like Windows 7!
    FYI originally posed here (but was advised to ask on Technet) - https://answers.microsoft.com/en-us/windows/forum/windows8_1-files/windows-81-network-share-0x8007003b-error-copying/300bc9a4-597b-402a-b885-9dd6f6fb51a2
    Thanks,
    Zak

    Hi MeipoXu,
    Sorry, it has taken me so long to reply. I thought I had subscribed to receive updates on this thread, but I didn't see anything!
    I've ran the commands you gave but some of them did not work, I got the following error: 
    Set global command failed on IPv4 The parameter is incorrect.
    However, output of current settings are below.
    TCP Global Parameters
    Receive-Side Scaling State          : disabled
    Chimney Offload State               : disabled
    NetDMA State                        : disabled
    Direct Cache Access (DCA)           : disabled
    Receive Window Auto-Tuning Level    : normal
    Add-On Congestion Control Provider  : none
    ECN Capability                      : disabled
    RFC 1323 Timestamps                 : disabled
    Initial RTO                         : 3000
    Receive Segment Coalescing State    : disabled
    Non Sack Rtt Resiliency             : disabled
    Max SYN Retransmissions             : 2
    To answer your original questions.
    Do you mean the file below 5 MB will copy fine ?
    5MB is not a hard limit. If the file is small enough it will copy before it errors out. A file of around 5MB or so fails with an error.
    Have you tried to copy the files from another Windows 8.1 machine (This will help us to verify whether the issue is casued by the specific machine)?Have you tried to copy another file from the network share to have a check ?
    Yes I've tried from another Windows 8.1 machine and have the same behaviour. It is the same with different files from the network share. And the same with different network shares.
    I am seeing nothing in the event viewer when the error occurs. I do not believe this to be a VPN issue because I can recreate this situation perfectly. As I mentioned in the original post- I
    also know it isn't an issue with this particular file share. I set up a little lab, where I had one VM which had a shared folder and 2 other client VMs one running Windows 7 and one running Windows 8.1. I limited the bandwidth to the two client VMs to a similar
    speed we see across our VPN. The result was that the Windows 8.1 failed with the same error above, whereas the Windows 7 copied fine.
    Basically, I had virtual machines all on the same local network. One virtual machine was hosting a file share with files on it. I created one Windows 7 VM and one Windows 8.1 VM. Using VMWare Workstation you can limit the network bandwidth to the VMs. When
    I did not limit the network bandwidth I could copy all files of all sizes fine. However, when I limit the network bandwidth to a speed of around 30-50KBps, the Windows 8.1 VM fails to copy files with the same error. But Windows 7 VM copies the files fine.
    The point of limiting the bandwidth in this way is to create a similar scenario to that I see when connecting over the VPN.
    This all leads me to believe there is some sort of issue with copying files from fileshares over slow connections using Windows 8.1.
    Cheers,
    Zak

  • Problem copying file from MacOSX 10.6.7 to WindosXP shared folder

    Hello Group,
                   I recently switched to mac os and I need to frequently copy files from mac to Windows XP shared network folder. I am getting following error
    Quote: 
    One or more items can’t be copied to “destfolder(in WinXP)” because you don’t have permission to read them. Do you want to copy the items you are allowed to read?
    These are the steps I followed:
    -> Finder-> Go to server-> SMB: Windows XP IP
    -> Open the destination folder in WIndows system
    -> Copy files from mac system to Windows system connected as per above steps
    I am struggling to copy files. ANy help would really be appreciated.
    regards,
    RB

    You mount the remote windows directory and copy files conveniently.
    mount -t cifs -o username=<win user>,password=<win pwd> //winserver/dir /winserver/dir
    where <win user> : Remote Windows Login Id
    <win pwd>: Windows login pwd
    //winserver/dir : Remote windows server and directory, you would like to access. You need to share it before mounting in MAC.
    /winserver/dir : Local diectory. You need to create it before mounting.
    Let me know if you need more info

  • Script for copying or moving files from windows server to another remote windows server

    Copy below 2 line into notepad and save as movescript.vbs
    execute in command prompt
    c:\cscript movescript.vbs  (Press ENTER)
    Files will move to remote location.
    =========================================
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.MoveFile "C:\scripts\*.txt","\\servername\c$\share"
    =========================================
    for copy files to remote location
    =========================================
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.CopyFile "C:\scripts\*.txt","\\servername\c$\share"
    =========================================
    Lets us know if you face any error. reply back to me on [email protected]
    Thank you.....
    Regards Ravikiran MCITP

    What is your question?  Are you asking how to do this?  Can you post the errors?
    ¯\_(ツ)_/¯

  • How can I copy file/folders from and to hard drives? How can I have two or more windows of explorer so that I can drag and drop from one hard drive to another?

    Hi,
    I am a new customer (purchased last week) of MacBookPro (latest) and its my first ever Apple laptop.
    I am almost lost to find the operating tools.
    1. How can I copy files from hard drive to computer and vis-a-versa?
    2. Only can browse one but how can I have two or more browses at the same time like in MS windows?
    3. No right click works on track pad?
    4. Is there application/ program compatible to MS office? If so how much and how can I purchase?
    5. Is there AutoCAD program that is compatible to MS Window AutoCAD? and if yes how much and how can I purchase?
    I will very much appreciate if you could email me the with the solution/answers please.
    Regards,
    Khagendra Limbu

    1) For some reason this happens once in a while with FAT32 enabled external harddrives. I have no idea why this happens but it most easily solved by reformatting the drive. First make sure you've copied everything from the external drive to your internal harddrive. You've done this earlier so I assume you know how to do this.
    Now the reformatting part. Open Finder and go to Applications. Look for the folder called "Utilities". Click on it. In it you find a program called "Disk Utility". Click on it. Now look for the external drive. You probably see two entries for the disk. Click on the one that contains the name of the drive NOT the one that describes the disk (Like for example 320.07 GB Samsung S2 Portable Media).
    Now you see four tabs in the righthand part of the window. They're called "First Aid", "Erase", "RAID" and "Restore". Click on "Erase". This opens the tab with (amongst others) a dropdownbox (Format) and a textbox (Name) . In the dropdownbox select "Mac OS Extended (Journaled). Take note! This selection disables usage of the drive with Windows PC's. If your goal is to share the drive with Windows PC's select the MS-DOS FAT option.
    Enter a label for the drive in the textbox Name. Now click on the button "Erase". This will format the drive.
    Now when it's done you can copy back all the items you've copied to your internal harddrive earlier.
    2) Opening two windows like Explorer on Windows is opening two Finder windows on the Mac. Simply click on the background. In the menubar you items like 'Finder", "File", "Edit", "View", et cetera. Click on "File" and "New Finder Window". Do this two times. Alternatively you can click on the background and press CMD-N two times.
    3) You can right click on the trackpad. This however depends on if you've enabled the feature in System Preferences. In the topmenubar click on the Apple icon and select "System Preferences". Now look for Trackpad in Hardware. Click on it. You see three tabs with the names "Point & Click", "Scroll & Zoom" and "More Gestures". Select "Point & Click" and look for "Secondary Click'. Make sure it is checked and make sure it has written "Click or tap with two fingers" written beneath "Secondary Click". When you're done exit System Preferences. Now select the background and tap with two fingers on the trackpad. This should open the contextuel menu with options like "New Folder", "Get Info" et cetera.

  • Error copying file when reinstalli​ng Windows

    I saw where someone had posted a similar question, but saw no answers. Anyway, IBM sent me a set of recovery disks and a new hard drive (unit it still under warranty) and when I try to reinstall using the recovery disks provided, it stops during disk 2 of 6. The progress bar stops just short of the end of it, and the total progress bar stops about 1/3 of the way through. I used an identical set to reinstall the operating system (IBM sent me two hard drives and two sets of recovery disks, one for each unit) on an identical machine and had the same problem. I received this error message each time in a "recov32" window that popped up:
    An error copying file D:\RECOVERY\CM2ZCUS.002
    ERROR 23: DATA ERROR (CYCLIC REDUNDANCY CHECK).
    What does this mean and how can I resolve it? When I hit "OK", it goes on to ask for disk 3 of 6, and so on.
    And while attempting the installation on both systems, it asked for a supplemental product recovery disk (the disk says product recovery supplemental disk) just prior to insertion of disk 1 of 6.....I put that disk in the drive and scant seconds later., then iit asks for it again after disk 6 of 6 has been installed.  Is that normal? Then when it tells me to power up again, I can't do it using the restart button on that page.....the window is not responsive and i have to it shut it down buy manually pressing the on button. Appears to repeat the installation all over again.
    At any rate, both installations have not been successful in restoring Windows XP Professional on these machines, and I'm in dire need of a solution!!
    moderator note: edited post to proper sentence case for readability.   please do not post in all caps as it makes things impossible to read.   any further posts in all caps will be deleted without warning.

    Sorry about the caps....didn't realize it'd be difficult to read.
    Anyway, regarding the possibility of scratched/damaged setup disks......I have two sets, one for each laptop, and both give me the error when I try to reinstall. Seems pretty coincidental that both sets would be damaged, unless IBM makes it a habit to send out faulty software. But I tried again, got the same error when Disk 2 was installing....I went ahead and clicked OK, it asked for the third disk and darned if it popped up with the same error, but with a different file (BKD047A.IMZ). However, I'm continuing the installation in spite of the errors, but don't hold out much hope that it will be successful. If it isn't, I'll try a set of XP Pro boot disks. If that fails, I'll try an installation CD for another laptop. After that, I don't know, unless I call IBM again and have them send me replacements for the two sets of disks. Unless anyone else has another idea??

  • ITunes no longer loads after updating to Windows 8.1.  I have tried every corrective step I've found on the web (reinstall, copy files, change permissions, etc.) nothing helps.  Has anyone heard if Apple is working on fix?

    Itunes does not launch after updating to Windows 8.1.  I've tried every suggestion I can find on web (reinstall, copy files from other directories, change permissions, etc.).  Nothing works.  At best I can get the licensing agreement to show and then nothing.  Has anyone heard if a fix is in the works?

    Hi 3backpacker3,
    It sounds like you are on the right track in troubleshooting this issue. If you are having launch issues, you may find the following article helpful:
    iTunes for Windows Vista or Windows 7: Troubleshooting unexpected quits, freezes, or launch issues
    http://support.apple.com/kb/ts1717
    Regards,
    - Brenden

  • A script for copying certain files to a new location

    I have a folder with over 50,000 images in it. I need about 15,000 of them copied to another folder.
    Is there a script (that I can paste the list of the ones I need copied) to perform this action?
    Thanks in advance.

    perhof,
    After much googling, I was fortunate enough to find your beautiful script!
    I added a couple of things like subfolder recusion ( by tweaking scripts I found) .
    Would you be kind enough to look this over and see if it's ok or needs fixing?
    Thanks for any help,
    ec
    [code]
    ' Read a list of images from text file
    ' and copy those images from SourceFolder\SubFolders to TargetFolder
    ' Should files be overwriten if they already exist? TRUE or FALSE.
    Const blnOverwrite = TRUE
    Dim objFSO, objShell, WSHshell, objFolder, objFolderItem, strExt, strSubFolder
    Dim objFileList, strFileToCopy, strSourceFilePath, strTargetFilePath
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Shell.Application")
    Set WSHshell = CreateObject("WScript.Shell")
    Const ForReading = 1
    ' Make the script useable on anyone's desktop without typing in the path
    DeskTop = WSHShell.SpecialFolders("Desktop")
    strFileList = DeskTop & "\" & "images.txt"
    ' File Extension type
    strExt = InputBox("Please enter the File type" _
    & vbcrlf & "For Example: jpg or tif")
    If strExt="" Then
       WScript.Echo "Invalid Input, Script Canceled"
    Wscript.Quit
    End if
    ' Get the source path for the copy operation.
    Dim strSourceFolder
    Set objFolder = objShell.BrowseForFolder(0, "Select source folder", 0 )
    If objFolder Is Nothing Then Wscript.Quit
    Set objFolderItem = objFolder.Self
    strSourceFolder = objFolderItem.Path
    ' Get the target path for the copy operation.
    Dim strTargetFolder
    Set objFolder = objShell.BrowseForFolder(0, "Select target folder", 0 )
    If objFolder Is Nothing Then Wscript.Quit
    Set objFolderItem = objFolder.Self
    strTargetFolder = objFolderItem.Path
    Set objFileList = objFSO.OpenTextFile(strFileList, ForReading, False)
    On Error Resume Next
    Do Until objFileList.AtEndOfStream
        ' Read next line from file list and build filepaths
        strFileToCopy = objFileList.Readline & "." & strExt
        ' Check for files in SubFolders
        For Each strSubFolder in EnumFolder(strSourceFolder)
          For Each strFileToCopy in oFSO.GetFolder(strSubFolder).Files
        strSourceFilePath = objFSO.BuildPath(strSubFolder, strFileToCopy)
        strTargetFilePath = objFSO.BuildPath(strTargetFolder, strFileToCopy)
        ' Copy file to specified target folder.
        Err.Clear
        objFSO.CopyFile strSourceFilePath, strTargetFilePath, blnOverwrite
        If Err.Number = 0 Then
            ' File copied successfully
            iSuccess = iSuccess + 1
            If Instr(1, Wscript.Fullname, "cscript.exe", 1) > 0 Then
                ' Running cscript, output text to screen
                Wscript.Echo strFileToCopy & " copied successfully"
            End If
        Else
            ' Error copying file
            iFailure = iFailure + 1
            TextOut "Error " & Err.Number & _
            " (" & Err.Description & ")trying to copy " & strFileToCopy
        End If
       Next
    Next
    Loop
    strResults = strResults + 0 '& vbCrLf
    strResults = strResults & iSuccess & " files copied successfully." & vbCrLf
    strResults = strResults & iFailure & " files generated errors" & vbCrLf
    Wscript.Echo strResults
    Sub TextOut(strText)
        If Instr(1, Wscript.Fullname, "cscript.exe", 1) > 0 Then
            ' Running cscript, use direct output
            Wscript.Echo strText
        Else
            strResults = strResults & strText & vbCrLf
        End If
    End Sub
    Function EnumFolder(ByRef vFolder)
    Dim oFSO, oFolder, sFldr, oFldr
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    If Not IsArray(vFolder) Then
    If Not oFSO.FolderExists(vFolder) Then Exit Function
    sFldr = vFolder
    ReDim vFolder(0)
    vFolder(0) = oFSO.GetFolder(sFldr).Path
    Else sFldr = vFolder(UBound(vFolder))
    End If
    Set oFolder = oFSO.GetFolder(sFldr)
    For Each oFldr in oFolder.Subfolders
    ReDim Preserve vFolder(UBound(vFolder) + 1)
    vFolder(UBound(vFolder)) = oFldr.Path
    EnumFolder vFolder
    Next
    EnumFolder = vFolder
    End Function
    [/code]

  • A script for copying smilar files to a new location

    Hi,
    i newbies to scripting. My challenge is that I want a script to only copy files with names "similar" and not "exactly the same" as the filenames in the text file.
    For example some files have 10 letters file name like "ABC01FGH01.tif".  I have to copy file where starting letter "ABC" and middle letter "FGH" of file name are fixed, but other letters are changed.
    The script sees a file name like "ABC**FGH**.tif", it should search the source location and copy the files having filenames with at least this characters e.g. "ABC02FGH02.tif", "ABC03FGH04.tif" should be copied since it has
    contains "ABC**FGH**.tif".
    Please help.

    Learn how to use wildcards in file names.  '*' is for any number of characters and'?' is for one character.
    COPY ABC??DE???.?x? c:\target
    Start by using DIR
    DIR ABC??DEF???JK.?x?
    ¯\_(ツ)_/¯

  • Windows 8.1 will not copy files from intranet site.

    I am using Windows 8.1 and I am trying to copy files from an Apple Time Capsule disk to a local hard drive. First I got the message box that said "Your Internet security settings suggest that one or more files may be harmful. Do you want to use it
    anyway?" and when I said okay nothing would copy. I went into my Internet options and added the Time Capsule disk to my site list in the Local Intranet Zone and reconnected the shared drive. Now I don't get the error box but it doesn't copy
    anything either. It does nothing. Any suggestions would be appreciated.
    Benjamin Greco Jr.

    I suggest you to run a malware check.. 
    May be its due to this malware "ZeroAccess rootkit/Sirefef"... What it does is it will block downloading and it will block you from visiting to some site... 
    Download and transfer this....
    Use one scanner at a time
    Download hitman pro 3.7  from uninfected pc and transfer to you pc and install (shareware and can be activated for 30 days free)and have a
    full system scan.. http://www.surfright.nl/en 
    alternatively you can use hitmanprokickstart usb bootable
    http://www.surfright.nl/en/kickstart
    And/or
    use malwarebyte  downloaded from uninfected pc and transfer to you pc and install and have a full system scan http://www.malwarebytes.org/products/malwarebytes_free/
    And/or
    use adwcleanerand  downloaded from uninfected pc and transfer to you pc and install and ave
    a full system scan..http://www.bleepingcomputer.com/download/adwcleaner/dl/125/)
    And/or
    use Junkware Removal  Tool  downloaded from uninfected pc and transfer to you pc and install andhave a full system scan
    http://www.bleepingcomputer.com/download/junkware-removal-tool/dl/131/
    And/or use TDSS Killer  downloaded from uninfected pc and transfer to you pc and
    install andhave a full system scan..: http://www.bleepingcomputer.com/virus-removal/remove-tdss-tdl3-alureon-rootkit-using-tdsskiller
    additional info
    If everything fails, you can use offline bootable resccue cd and do a full system scan... 
    https://support.kaspersky.com/viruses/rescuedisk
    http://windows.microsoft.com/en-us/windows/windows-defender-offline-faq
    How to create a defender offline bootable cd/pendrive
    http://www.pcandtablet.com/windows-8-antivirus-and-security/546/how-to-create-a-windows-defender-offline-usb-stick-to-remove-malware-on-windows-8-a.html
    Hetti Arachchige V Aravinda | Network & System Administrator (B.Sc, Microsoft Small Business Specialist, MCP, MCTS, MCSA, MCSE,MCITP, CCNA, CEH, MBCS)

Maybe you are looking for