Re: Copy files with rename messagebox

From: Al Dunbar [MS-MVP] (alan-no-drub-spam_at_hotmail.com)
Date: 02/08/05


Date: Mon, 7 Feb 2005 20:11:07 -0700


"Dirk Schroeyers" <swiftwegmetdit1977@yahoo.com> wrote in message
news:Xns95F660876B2C1swiftwegmetdit1977ya@195.238.0.34...
> Hello everyone,
>
> I would like to know if it is possible to use an vbscript to move a
> variable amount of files from one location to another and at the same time
> showing a messagebox per moved file, where an user can enter a new name
> under which each file will be saved at their new location. If the user
> tries to give one file the same name as an existing file it would be nice
> if he or she gets an warning.
> This will make sure older files will not be overwritten by newer files
with
> the same name.
> Can this be done?

Yes it can. But if the "variable amount" is a large number, the user will
get pretty tired of having to interactively come up with a different name
for each file as it is presented to him. Perhaps an alternative approach
would be that the new name be calculated from the old name by prefixing it
with something like the current date/time, current user account, or
something along those lines.

Anyway, it is not a MSGBOX you want, but an INPUTBOX; consider the following
pseudocode:

    ' initialize; determine source and destination locations.
    for each file in filecollection
        newname = inputbox("enter new name for file: " & file, "file move
utility", file )
        move/rename file as newname
    next

That may be a bit of an oversimplification. Supposing you wanted to move
file C.txt from C:\A\ to C:\B\ under new name D.txt, and you have already
determined that no file by the name C:\B\D.txt exists. You could rename it
and then move it, but if a file named D.txt already exists in C:\A\, this
would fail. In that event, you could move it first and then rename it, but
that would fail if a file named A.txt already existed in C:\B\. Simplest
solution would be to rename it to a temp name that exists in neither
location, move it, then rename to the desired name.

/Al



Relevant Pages

  • Re: Copy files with rename messagebox
    ... > could rename it and then move it, but if a file named D.txt already ... Simplest solution would be to rename it to a ... The "variable amount" is not that large, I think we're talking about 3, ... with the temp name)... ...
    (microsoft.public.scripting.vbscript)
  • Re: Another fine mess
    ... jobs can fail every minute. ... [[If rename fails, and there is no C, subsequent jobs fail. ... The information contained in this communication (including any ...
    (bit.listserv.ibm-main)
  • Re: Name function in Access 2002 (XP)
    ... There are *myriads* of reasons that a rename can fail, ... the new file name is invalid; ... The VBA errors are very specific when there is a problem. ...
    (microsoft.public.access.formscoding)
  • Re: WMI/VB Script to rename multiple computers in a domain
    ... For this type of task I always turn to NETDOM. ... You should be able to use it remotely and call it from a VBScript. ... It will take care of updating the computer object in AD. ... I need help to device a script that can rename multiple computers in my ...
    (microsoft.public.windows.server.scripting)
  • Re: Newbie help:rename each file in a folder?
    ... I don't know the difference between VB and VBScript, ... >> a set number of characters, with only the final character of the name ... >> the file name into a string, then Rename each file. ... >> Dim fso, fldr, fil, fname ...
    (microsoft.public.vb.general.discussion)