Sign in to follow this  
Followers 0
Cryptor

Please help @ rename a file

8 posts in this topic

#1 ·  Posted (edited)

Hi, i will download a file with wget.

I will rename the file in my autoit script. I can´t! Please help! :">

Download the newest file

bla32*.exe

Rename the file

bla32.*date*.exe to bla32.exe

Run the file

bla32.exe

RunWait(@ComSpec & " /c " & 'wget.exe -P %snapshotpath% ftp://ftp......../bla32*.exe', "",)
    Run(@ComSpec & " /c" & '%snapshotpath%bla32.exe',"", @SW_HIDE)

DOS Code

wget.exe ftp://ftp......../bla32*.exe
ren bla32*.exe bla32.exe
start bla32.exe

:D

Edited by Cryptor

Share this post


Link to post
Share on other sites



Hi,

have a look at FileMove.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi, i will download a file with wget.

I will rename the file in my autoit script. I can´t! Please help! :">

Download the newest file

bla32*.exe

Rename the file

bla32.*date*.exe to bla32.exe

Run the file

bla32.exe

RunWait(@ComSpec & " /c " & 'wget.exe -P %snapshotpath% ftp://ftp......../bla32*.exe', "",)
    Run(@ComSpec & " /c" & '%snapshotpath%bla32.exe',"", @SW_HIDE)

DOS Code

wget.exe ftp://ftp......../bla32*.exe
ren bla32*.exe bla32.exe
start bla32.exe

:wacko:

So... the files have some kind of date/time stamp formatted into the file name? Your DOS code assumes that the files will be renamed by REN in sorted file name order, which I wouldn't count on being consistent, and I think in most environments renaming multiple files to a single file name would be considered a broken function. (Lots of things are broken and funky in DOS/CMD shell).

It would be easy to find the file with latest date/time stamp using FileFindFirstFile() and FileFindNextFile(). If you don't see how, just post a couple of examples of the filename formatting.

:D

P.S. @th.meger: FileMove() will take a wildcard for source and destination, but won't it generate an error if there is a wildcard in the source but not in the destination? I've never tried it, and don't have a Windows box to ttest it on. :D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

P.S. @th.meger: FileMove() will take a wildcard for source and destination, but won't it generate an error if there is a wildcard in the source but not in the destination? I've never tried it, and don't have a Windows box to ttest it on. :D

Hi,

no won't error out. No problem there. :wacko:

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I can´t! Please help!

Here is the script. Test it please and help me to rename the downloaded file after download in the %snapshotpath%.

:D

Attachment File with the .au3 Script & wget.exe

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

AutoItSetOption("TrayIconHide", 1)

GuiCreate("Download NOD32 Antivirus", 330, 220)
GuiSetIcon("nod.ico")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

GUICtrlCreateGroup ("Proxy server ", 10, 10, 310, 90)
$PROXYID = GUICtrlCreateCheckbox("Use a proxy server for your LAN connection", 30, 30, 235, 20)
GUICtrlSetOnEvent($PROXYID,"OnProxy")
GUICtrlCreateLabel("Address:", 50, 62, 50, 20)
GUICtrlSetState(-1,$GUI_DISABLE)
$ipaddy=GUICtrlCreateInput("", 100, 60, 95, 20)
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlCreateLabel("Port:", 220, 62, 30, 20)
GUICtrlSetState(-1,$GUI_DISABLE)
$port=GUICtrlCreateInput("", 250, 60, 40, 20)
GUICtrlSetState(-1,$GUI_DISABLE)
$useproxy ="no"
GUICtrlCreateGroup ("",-99,-99,1,1)  ;close group

GUICtrlCreateGroup ("Download and launch from ", 10, 110, 310, 70)
GUICtrlCreateLabel("Location:", 30, 142, 50, 20)
$save=GUICtrlCreateInput("B:\", 85, 140, 205, 20)
GUICtrlCreateGroup ("",-99,-99,1,1)  ;close group
GUICtrlCreateLabel("v0.1 - ©2006 by Cryptor", 10, 200, 120, 20)

$OKID = GuiCtrlCreateButton("OK", 160, 190, 75, 23)
GUICtrlSetOnEvent($OKID,"OnOK")
$CANCELID = GuiCtrlCreateButton("Cancel", 245, 190, 75, 23)
GUICtrlSetOnEvent($CANCELID,"OnCANCEL")

GUISetState ()

While 1

Wend

;--------------- Functions ---------------
Func OnProxy()
If GUICtrlRead($PROXYID) = "1" then
    GUICtrlCreateLabel("Address:", 50, 62, 50, 20)
    $ipaddy=GUICtrlCreateInput("", 100, 60, 95, 20)
    GUICtrlCreateLabel("Port:", 220, 62, 30, 20)
    $port=GUICtrlCreateInput("", 250, 60, 40, 20)
    $useproxy ="yes"

ElseIF GUICtrlRead($PROXYID) = "4" then
    $ipaddy=""
    $port=""
    GUICtrlCreateLabel("Address:", 50, 62, 50, 20)
    GUICtrlSetState(-1,$GUI_DISABLE)
    GUICtrlCreateInput("", 100, 60, 95, 20)
    GUICtrlSetState(-1,$GUI_DISABLE)
    GUICtrlCreateLabel("Port:", 220, 62, 30, 20)
    GUICtrlSetState(-1,$GUI_DISABLE)
    GUICtrlCreateInput("", 250, 60, 40, 20)
    GUICtrlSetState(-1,$GUI_DISABLE)
    $useproxy ="no"
EndIf
EndFunc

Func OnOK()
If $useproxy = "no" Then
    $location = GUICtrlRead($save)
    envset ("snapshotpath", $location)
Else
    $location = GUICtrlRead($save)
    $paddress = GUICtrlRead($ipaddy)
    $pport = GUICtrlRead($port)
    $ipaddyport = $paddress & ":" & $pport
    envset ("http_proxy", $ipaddyport)
    envset ("ftp_proxy", $ipaddyport)
    envset ("snapshotpath", $location)
EndIf
    GUIDelete()
    RunWait(@ComSpec & " /c " & 'wget.exe -P %snapshotpath% ftp://ftp.isu.edu.tw/pub/Windows/Edskes/n/nod32*.exe', "",)

    Run(@ComSpec & " /c" & '%snapshotpath%nod32.exe',"", @SW_HIDE)
    Exit

EndFunc
Exit

Func OnCANCEL()
    Exit
EndFunc

Func SpecialEvents()
    If @GUI_CTRLID = $GUI_EVENT_CLOSE Then Exit

EndFunc

Share this post


Link to post
Share on other sites

Hi,

you can just use something like this to download and name your file as wished.

#include <file.au3>
InetGet('ftp://ftp.isu.edu.tw/pub/Windows/Edskes/n/00_index.txt', @TempDir &'\index.txt', 1,0)

Dim $aRecords
If Not _FileReadToArray(@TempDir & '\index.txt', $aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $aRecords[0]
    If StringInStr($aRecords[$x], 'nod') <> 0 Then 
    Local $exe =_StringBetween1($aRecords[$x], 0 , ' ')
    EndIf
Next

InetGet('ftp://ftp.isu.edu.tw/pub/Windows/Edskes/n/' & $exe, @ScriptDir & '\nod32.exe', 1)

Func _StringBetween1($s_String, $s_Start = 0, $s_End = 0)
    $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start)
    Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start)
EndFunc   ;==>_StringBetween1

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

you Pmed me. But I didn't see your problem?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

you Pmed me. But I didn't see your problem?

So long,

Mega

I become a error after run the script from you.

can you edit my script with your entries?

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