+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12

Thread: Multiple Copy and Rename of File...

  1. #11
    aka RF; RadioactiveFrog grae.uk will become famous soon enough grae.uk's Avatar
    Join Date
    Oct 2008
    Posts
    211
    Rep Power
    4

    Quote Originally Posted by jmurrayhead View Post
    thanks J. I actually wasn't doing anything wrong..the file for some strange reason was empty!

    the 'loop' should hav ebeen 'next' so changed that...

    This is the current code

    Code:
    strFiles = InputBox("Input file names seperated by commas.", "Names")
    arrFiles = split(strFiles,",")
    strSource = "dbfront.mdb"
    
    set oFSO = CreateObject("Scripting.FileSystemObject")
    
    for i = 0 to UBound(arrFiles)
    	strDestination = "dbfront_" & arrFiles(i) & ".mdb"
    	oFSO.CopyFile "x:\db_frontEnd\" & strSource, "x:\db_frontEnd\" & strDestination
    next
    
    Set oFSO = Nothing
    
    Going to see if I can modify it a bit.

    Grae
    “There are two theories to argueing with women. Neither of them work! ” - Unknown

  2. #12
    aka RF; RadioactiveFrog grae.uk will become famous soon enough grae.uk's Avatar
    Join Date
    Oct 2008
    Posts
    211
    Rep Power
    4

    Hey All,
    Modified it so that it now
    1) will determine the current directory, so if you run this from the directory where the file is that you want to copy and rename it will sort that bit
    2) you can enter the name of the file to copy in the process so it isn't hard coded

    easy for many I am sure, but a little challenge for me!

    There is aShowOpen function that can be used if the user is using XP or earlier, but I am running Vista so that wasn't going to work and coouldn't find a way round it..so chose to make the user type it in...not to hard really

    so here it is ...

    Code:
    'get the current path
    sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
    
    origFile = InputBox("Write the filename including extension you wish to copy.", "File to Copy")
    strFiles = InputBox("Input file names seperated by commas.", "Names")
    
    arrFiles = split(strFiles,",")
    strSource = split(origFile,".")
    
    set oFSO = CreateObject("Scripting.FileSystemObject")
    
    for i = 0 to UBound(arrFiles)
    	strDestination = strSource(0) & "_" & arrFiles(i) & "." & strSource(1)
    	oFSO.CopyFile sCurPath & "\" & origFile, sCurPath & "\" & strDestination
    
    next
    
    Set oFSO = Nothing
    
    wscript.echo "All finished."
    
    “There are two theories to argueing with women. Neither of them work! ” - Unknown

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. enhance copy and paste?
    By Centurion in forum ASP Development
    Replies: 3
    Last Post: April 27th, 2009, 10:18 AM
  2. Copy record
    By Rebelle in forum ASP Development
    Replies: 2
    Last Post: April 20th, 2009, 01:42 PM
  3. Trying to copy a record from one table to another
    By bryceowen in forum SQL Development
    Replies: 10
    Last Post: April 14th, 2009, 08:51 PM
  4. multiple div in .net page
    By guddu in forum .NET Development
    Replies: 9
    Last Post: February 18th, 2009, 12:30 PM
  5. Multiple Updates
    By Shem in forum .NET Development
    Replies: 4
    Last Post: July 8th, 2008, 02:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO