+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Multiple Copy and Rename of File...

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

    Multiple Copy and Rename of File...

    Hey All,
    Not sure this is the best place for this...but will be moved I am sure if not

    I want to create a script that I can run to copy a file and rename the copy, as I very often have to multiple copies of one file with different names (mainly database access files...but that is another story).

    So what I would like to do is this..

    copyNrename_function(wendy, cliff)

    So that is just calling the script from the commandline or something and the names in the brackets are part of the rename bit...so the files would be renames as follows

    front_wendy
    front_cliff

    Obv the ability to have as many names in those brackets ..

    Is that at all possible????

    Thanks guys!!

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

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Sure it is...pass a comma-delimited string as the parameter and use VBScripts' Split function to separate each name. Then loop through and copy and rename the files.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #3
    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
    Sure it is...pass a comma-delimited string as the parameter and use VBScripts' Split function to separate each name. Then loop through and copy and rename the files.
    Ok thanks J. Will come up with a script and might be back for some help

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

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

    Hey J et Al..

    Here is my first poor attempt and an idea...i suspect there are more errors in there than anything else...but other than editing VB in Access DB's not really played with it so it is a combination of what I kinda know and what I ahve read...

    Downloading VB Express 2008 now to see if that helps

    but here is my code...advice on the principle would be apprecaited...

    Code:
    Public Function duplicate_and_rename(name_list)
    
    Dim name_array() AS String = Split(name_list)
    Dim array_count As Integer
    
    array_count = Count(name_array)
    
    For i = 0 To array_count
    SourceFile = "dbfront.mdb"
    DestinationFile = "dbfront_" & array_count[i] & ".mdb"
    FileCopy(SourceFile, DestinationFile)
    Loop
    
    End Function
    
    Cheers,

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

  5. #5
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    i have used a vbscript that i wrote, where it would give you a popup box that you can use to input your comma delimited filenames and it would take that and do it's other things. something like this:
    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 "c:\" & strSource, "c:\" & strDestination
    loop
    
    Set oFSO = Nothing
    
    then save the file as a filename.vbs file and run it using either CScript from a command prompt or Wscript from with in windows.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

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

    wow, thanks mehere! I will give it a go, much apprecaited
    “There are two theories to argueing with women. Neither of them work! ” - Unknown

  7. #7
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    you could make it completely generic by allowing for another input box for your source file as well ...
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  8. #8
    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 mehere View Post
    you could make it completely generic by allowing for another input box for your source file as well ...
    yeah I was thinking about it, once I get to grips with it and all
    I'lll post anything up here if I make it do more!

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

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

    ok...struggling to run this...prob me being stupid. Tried running the following

    wscript x:\multi_copy.vbs

    from both a command line and the run prompt...

    nothing happens at all....

    any idas????

    thanks.

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

  10. #10
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread
Page 1 of 2 1 2 LastLast

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