Jump to content

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


Recommended Posts

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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!

#)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

:):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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...