Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - new name of copied file

Reply
 
Old 09-08-2008   #1 (permalink)
Norbert Römer


 
 

new name of copied file

hello,
I am new here and a beginner in vbscript. perhaps you can help me?
I have made the following script and its ok:

Sub test
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile "c:\bild.gif", "d:\"
End Sub

But what I have to do, if I want to give a new name to the copied file?
For example, the new filename should not be "bild.gif", but "newbild.gif"...

Thankyou for help
Norbert



My System SpecsSystem Spec
Old 09-08-2008   #2 (permalink)
Tom Lavedas


 
 

Re: new name of copied file

On Sep 8, 10:38*am, "Norbert Römer" <nroe...@xxxxxx> wrote:
Quote:

> hello,
> I am new here and a beginner in vbscript. perhaps you can help me?
> I have made the following script and its ok:
>
> Sub test
> Dim fso, MyFile
> Set fso = CreateObject("Scripting.FileSystemObject")
> fso.CopyFile "c:\bild.gif", "d:\"
> End Sub
>
> But what I have to do, if I want to give a new name to the copied file?
> For example, the new filename should not be "bild.gif", but "newbild.gif"....
>
> Thankyou for help
> Norbert
Have you tried ...

fso.CopyFile "c:\bild.gif", "d:\newbild.gif"

My reading of the WSH documents indicates that works or is there more
to your question than I see here?

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec
Old 09-09-2008   #3 (permalink)
Norbert Römer


 
 

Re: new name of copied file

OK, it works,
many thanks. But the specific problem ist, that I have to use a variable
term, not "d:\newbild.gif". If I write

set variable= "d:\newbild.gif"
fso.CopyFile "c:\bild.gif", variable

the I get errors.

thanks
Norbert


"Tom Lavedas" <tglbatch@xxxxxx> schrieb im Newsbeitrag
news:7430803a-b876-4772-ab84-0a604ef34d4b@xxxxxx
On Sep 8, 10:38 am, "Norbert Römer" <nroe...@xxxxxx> wrote:
Quote:

> hello,
> I am new here and a beginner in vbscript. perhaps you can help me?
> I have made the following script and its ok:
>
> Sub test
> Dim fso, MyFile
> Set fso = CreateObject("Scripting.FileSystemObject")
> fso.CopyFile "c:\bild.gif", "d:\"
> End Sub
>
> But what I have to do, if I want to give a new name to the copied file?
> For example, the new filename should not be "bild.gif", but
> "newbild.gif"...
>
> Thankyou for help
> Norbert
Have you tried ...

fso.CopyFile "c:\bild.gif", "d:\newbild.gif"

My reading of the WSH documents indicates that works or is there more
to your question than I see here?

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/


My System SpecsSystem Spec
Old 09-09-2008   #4 (permalink)
Richard Mueller [MVP]


 
 

Re: new name of copied file

Don't use the "Set" keyword when assigning values to string variables. It's
used only for assigning object references. Does it work if you use?

variable = "d:\newbild.gif"

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"Norbert Römer" <nroemer@xxxxxx> wrote in message
news:48c6513c$0$18729$9b4e6d93@xxxxxx-online.net...
Quote:

> OK, it works,
> many thanks. But the specific problem ist, that I have to use a variable
> term, not "d:\newbild.gif". If I write
>
> set variable= "d:\newbild.gif"
> fso.CopyFile "c:\bild.gif", variable
>
> the I get errors.
>
> thanks
> Norbert
>
>
> "Tom Lavedas" <tglbatch@xxxxxx> schrieb im Newsbeitrag
> news:7430803a-b876-4772-ab84-0a604ef34d4b@xxxxxx
> On Sep 8, 10:38 am, "Norbert Römer" <nroe...@xxxxxx> wrote:
Quote:

>> hello,
>> I am new here and a beginner in vbscript. perhaps you can help me?
>> I have made the following script and its ok:
>>
>> Sub test
>> Dim fso, MyFile
>> Set fso = CreateObject("Scripting.FileSystemObject")
>> fso.CopyFile "c:\bild.gif", "d:\"
>> End Sub
>>
>> But what I have to do, if I want to give a new name to the copied file?
>> For example, the new filename should not be "bild.gif", but
>> "newbild.gif"...
>>
>> Thankyou for help
>> Norbert
>
> Have you tried ...
>
> fso.CopyFile "c:\bild.gif", "d:\newbild.gif"
>
> My reading of the WSH documents indicates that works or is there more
> to your question than I see here?
>
> Tom Lavedas
> ===========
> http://members.cox.net/tglbatch/wsh/
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Monitor a file, generate log when it was copied VB Script
Copied file has System and Hidden attribute set. .NET General
file has properties that cannot be copied Vista General
Drops Network when large file copied to PC Vista General
File Manager doesn't display WHAT file is being copied/moved!?!?!?! Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46