Jump to content
Sign in to follow this  
well-knownQ8

Which is better FileMove() or "ren" Command ?

Recommended Posts

well-knownQ8

Hi :)

1st of all, i'm very pleased for joining autoit forums, and want to thank the brilliant team that made this great scripting language :mellow:

and i have this question...

Which is better (in performance) for renamining ... using FileMove() or the dos command "ren" ?

======

Thanks in Advance :)

Share this post


Link to post
Share on other sites
well-knownQ8

I think FileMove, because calling:

Run("ren"&$whatever)

in a script runs a new application and is slower.

thnx for the reply :)

mmmm.....maybe.

but what about the function FileMove itself !!

isn't it uses two functions (moving then renaming) !?

Share this post


Link to post
Share on other sites
Lord_Doominik

hm, i would use FIleMove()... as far as i know it's not a dos function and so it should be faster... and as far as i know it use just 1 function, for renaming while moving :).

Share this post


Link to post
Share on other sites
ChrisL

Hi :)

1st of all, i'm very pleased for joining autoit forums, and want to thank the brilliant team that made this great scripting language :mellow:

and i have this question...

Which is better (in performance) for renamining ... using FileMove() or the dos command "ren" ?

======

Thanks in Advance :)

I'd be supprised if there was much difference

Share this post


Link to post
Share on other sites
well-knownQ8

I'd be supprised if there was much difference

I think there is a diffrence...

and i've tried searching about FileMove's code, but i didn't fine any !

...

i'm thinking about making a simple test, to see that, thought...

Share this post


Link to post
Share on other sites
Lord_Doominik

hm, you could take you the time and test which is faster, but i think it don't matters much... if one is faster then just a few 1/1000 seconds

Share this post


Link to post
Share on other sites
well-knownQ8

hm, you could take you the time and test which is faster, but i think it don't matters much... if one is faster then just a few 1/1000 seconds

Sorry.. I doubt it !!!

Guys... You'll not beleive the results.. !!!!

wait till next post :)

Share this post


Link to post
Share on other sites
SmOke_N

Well the fact that you said that makes me think the DOS commands are better... hope you provide a good example!


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
nfwu

I have an idea... i transfer a 1GB file from my ultra-slow 250GB External Drive to my harddrive using both methods!

Wait up for the results!

#)

Share this post


Link to post
Share on other sites
well-knownQ8

I have an idea... i transfer a 1GB file from my ultra-slow 250GB External Drive to my harddrive using both methods!

Wait up for the results!

#)

:):o

--------------and now the results....

first, i was preparing a table for running from 1000 to 100,000

but from the begining the winner appears..

for "Ren" Command (1,000 files)

I ran it 4 times and the average was 57 seconds !!!

For FileMove Function it took 3.2 Seconds in average !!!

what a score... :)

any comments ? :mellow:

Edited by well-knownQ8

Share this post


Link to post
Share on other sites
SmOke_N

:):o

--------------and now the results....

first, i was preparing a table for running from 1000 to 100,000

but from the begining the winner appears..

for "Ren" Command (1,000 files)

I ran it 4 times and the average was 57 seconds !!!

For FileMove Function it took 3.2 Seconds in average !!!

what a score... :)

any comments ? :mellow:

Care to provide the code that you used?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
nfwu

Posted Image

oh yar, i used the move command.

EDIT: ren command only allows rename within the current directory... so i had to use move...

My code:

#cs
File: myp_maya7ple_en_win.exe
Maya7 PLE Installation File

===========
Type: Application
Discription: myp_maya7ple_en_win
===========
Location: C:\Documents and Settings\Owner\Desktop\Alex\ExeAndZip\InstallationExes
Size: 261 MB (274,455,619 bytes)
Size On Disk: 261 MB (274,456,576 bytes)
===========
Created: Tuesday, October 25, 2005, 5:43:32 PM
Modified: Tuesday, October 25, 2005, 5:42:10 PM
Accessed: Today, March 15, 2006, 5:30:38 PM
==========
All times are +8 GMT.
#ce

$from = '"C:\Documents and Settings\Owner\Desktop\Alex\ExeAndZip\InstallationExes\Copy (2) of myp_maya7ple_en_win.exe"'
$to = '"J:\test_1.exe"'
$from2 = 'C:\Documents and Settings\Owner\Desktop\Alex\ExeAndZip\InstallationExes\Copy (3) of myp_maya7ple_en_win.exe'
$to2 = 'J:\test_2.exe'
PluginOpen("J:\Alex\Programming\autoit scrips and scraps\Au3Console\Au3Console\Au3Console.dll")
ConsoleLoad("TEST CONSOLE")
Sleep(5000);; Wait for AutoIt to get ready...
ConsolePrint("Starting DOS move command..."&@CRLF)
$time = TimerInit()
RunWait(@ComSpec & ' /c move '&$from&' '&$to, '', @SW_HIDE)
ConsolePrint(TimerDiff($time)&": Time for DOS move command..."&@CRLF)
Sleep(10000);;Wait for Windows to clear my drive's catche
ConsolePrint("Starting AutoIt FileMove command..."&@CRLF)
$time = TimerInit()
FileMove($from2, $to2)
ConsolePrint(TimerDiff($time)&": Time for AutoIt FileMove command..."&@CRLF)
MsgBox(0,"", "Test Complete.")
Edited by nfwu

Share this post


Link to post
Share on other sites
well-knownQ8

Care to provide the code that you used?

ok

first copying 1000 file from the file test.txt

For $i=0 To 1000
    FileCopy("E:\Test\Renaming\test.txt","E:\Test\Renaming\test"&$i&".txt")
Next

Then

$path = "E:\Test\Renaming"
For $i=0 To 1000
;~  FileMove($path & "\ren_to"&$i&".txt", $path& "\test"&$i&".txt")
    Run(@ComSpec & " /c " & 'ren '& """"&$path & "\test" & $i & ".txt""" & _
        " "& "ren_to"&$i&".txt","",@SW_HIDE)
Next

running it once for Filemove, then once for Ren.

as u can see this is a case for renaming file after file, (normal N times Loop).

Share this post


Link to post
Share on other sites
nfwu

ok

first copying 1000 file from the file test.txt

For $i=0 To 1000
    FileCopy("E:\Test\Renaming\test.txt","E:\Test\Renaming\test"&$i&".txt")
Next

Then

$path = "E:\Test\Renaming"
For $i=0 To 1000
;~  FileMove($path & "\ren_to"&$i&".txt", $path& "\test"&$i&".txt")
    Run(@ComSpec & " /c " & 'ren '& """"&$path & "\test" & $i & ".txt""" & _
        " "& "ren_to"&$i&".txt","",@SW_HIDE)
Next

running it once for Filemove, then once for Ren.

as u can see this is a case for renaming file after file, (normal N times Loop).

Maybe the slowdown was caused be too many concatenations?

#)

EDIT: PS. I sort of regret doing that copy maya installation thing... need 2 restart my com... accessing J: drive is just taking too long!

Edited by nfwu

Share this post


Link to post
Share on other sites
well-knownQ8

Maybe the slowdown was caused be too many concatenations?

we don't know.

but also in ur case (Moving), the results are very interesting...

so "move" (dos command) is way better than "FileMove" Function !

great :)

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  

×