Sign in to follow this  
Followers 0
anixon

Copy Move and Rename

4 posts in this topic

This is a piece of code which copies a file and moves it to another directory with a new name. Whilst my code works without any problems Is their a more efficient way of achieving the same outcome?

CODE
$var = FileSaveDialog("Choose a Name", @scriptdir & "\DataFiles\MsgLibrary\", "All (*.*)", 2)

Dim $szDrive, $szDir, $szFName, $szExt

$splitcsv = _PathSplit($var, $szDrive, $szDir, $szFName, $szExt)

$Cfile = $szFName & $szExt

FileCopy($var, @scriptdir & "\DataFiles\MsgLibrary\Move\",9)

FileMove(@scriptdir & "\DataFiles\MsgLibrary\Move\" & $CFile, @scriptdir & "\DataFiles\defaultmsg\test.csv", 9)

Cheers

Ant...

Share this post


Link to post
Share on other sites



What can I see so far:

$var = FileSaveDialog("Choose a Name", @scriptdir & "\DataFiles\MsgLibrary\", "All (*.*)", 2)       ;here you get the full path
Dim $szDrive, $szDir, $szFName, $szExt
$splitcsv = _PathSplit($var, $szDrive, $szDir, $szFName, $szExt)                    ;you do this to get the filename
$Cfile = $szFName & $szExt
FileCopy($var, @scriptdir & "\DataFiles\MsgLibrary\Move\",9)                          ;copy the file to your script dir
FileMove(@scriptdir & "\DataFiles\MsgLibrary\Move\" & $CFile, @scriptdir & "\DataFiles\defaultmsg\test.csv", 9)    ;move the file to the new locationoÝ÷ Ûú®¢×¶ÇÚ&zØZµ§(º^¶§Æ«zì¢W­zØ^¥ªí¶¶Ø^~)^©Ê zÛayû¥­úèX¥y&¯x8*ºZÛax*)Ëó(½ì!Êz-qØ«yË¢¢µ8b²ÈhºW]¢Ø^±©¶§«­¢+ØÀÌØíÙÈô¥±MÙ¥±½ ÅÕ½Ðí
¡½½Í9µÅÕ½Ðì°ÍÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈíÑ¥±ÌÀäÈí5Í1¥ÉÉäÀäÈìÅÕ½Ðì°ÅÕ½Ðí±° ¨¸¨¤ÅÕ½Ðì°È¤)¥±
½Áä ÀÌØíÙÈ°ÍÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈíÑ¥±ÌÀäÈíձѵÍÀäÈíÑÍйÍØÅÕ½Ðì°ä¤

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Thanks for that it works perfectly.

When I searched the Forum the solution offered was 'filemove' which I guess got me off on the wrong foot.

That solution just gave me another problem which was how to preserve the origional file hence the convoluted process.

I guess with code there is always more than one way of achiving a working outcome you just have to make sure that you have the most elegant way (economical) way. Thanks for the direction

Cheers Ant..

Share this post


Link to post
Share on other sites

Glad it worked :)

And indeed - there are countless ways to do the same thing but , unfortunately we can't see always the shortest way ... you know, this is like you're watching a chess game - when you're not one of the players you can think better moves more easy :D


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0