Jump to content

clean up files after script is done


Recommended Posts

Hello AutoIt people,

I've been trying to learn some basic coding using AutoIt-V3,

now i made a automated process that renames a file copies the renamed file to a temp folder and loads the rest of the proces

all this works great.

now i have only a few issues:

I would like to reduce the user interaction to a minimum, anyone an idea on how to achieve this

also i would like to let it clean up the files after the script is done ( empty the temp folder and delete all files in extracted.coldboot except the created .dds files from the used exe)

$Anim_1 = "sourceAnim_1.jpg"
$Coldboot = "tempColdboot.raf"
FileCopy($Anim_1,$Coldboot)
If FileExists($Coldboot)Then
   MsgBox(0000,"NOTICE","Remove the first 16bits,save and close the editor")
Else
   MsgBox(0000,"ERROR","OOPS! something went wrong,make sure that the Anim_1.jpg is in the source folder")
   Exit
EndIf
RunWait("toolsHex editHexFrame.exe tempcoldboot.raf")
MsgBox(0000,"NOTICE","browse for the coldboot.raf (in the temp folder),select decompress and press start,then close the program")
Run("toolsSimplyZipSimplyZip.exe")
WinWaitActive("Simplyzip version 1.1b78 (c) 2001, 2011 by Dirk Paehl freeware")
Send("!EZ")
WinWaitClose("Simplyzip version 1.1b78 (c) 2001, 2011 by Dirk Paehl freeware")
ProgressSet(60,"percent")
RunWait("toolsp3textractorp3textractor.exe tempcoldboot")
Msgbox(0000,"ready to convert","almost done")
RunWait("rename gim to gtf.exe")
Msgbox(0000,"done","just drag and drop all gtf files from extracted.coldboot onto gtf2dds.exe")
Run("explorer.exe sdkhost-win32bin")
Run("explorer.exe extracted.coldboot")
FileDelete("tempcoldboot.raf")
FileDelete("tempcoldboot")
MsgBox(0000,"Finished","thank you for using my script")
Exit

the executable of the script (credits for the extension renamer go to WeaponX)

download

Edited by kawaiitenshi
Link to comment
Share on other sites

I would like to reduce the user interaction to a minimum, anyone an idea on how to achieve this

When you said the above, did you mean to lock the keyboard and the mouse. if so then you can use the BlockInput ( flag ) function.

also i would like to let it clean up the files after the script is done ( empty the temp folder and delete all files in extracted.coldboot except the created .dds files from the used exe)

Why not just create another folder within the temp folder of "coldboot" like "coldbootdds files" then keep them there or move them to another folder before deleting the "coldboot" folder.

FileDelete("tempcoldboot.raf")
FileDelete("tempcoldboot")

Use DirRemove ( "tempcoldboot", 1 ) to remove all the files and folder in that folder Not FileDelete() because this function only deletes files not folders.
Link to comment
Share on other sites

When you said the above, did you mean to lock the keyboard and the mouse. if so then you can use the BlockInput ( flag ) function.

with user interaction i mean that the user doesn't have to do anything after the script starts ( now the user has to edit the loaded file in the hex editor himself ,look for the edited file during the decompression process,choose the extracted.coldboot folder enter original extension,enter new extension,drag and drop dds files onto an exe, remove all files made during the script.)

Why not just create another folder within the temp folder of "coldboot" like "coldbootdds files" then keep them there or move them to another folder before deleting the "coldboot" folder.

the thing is i need some kind of script that monitors the folder and when all the dds files are created moves them to a seperate folder (i can't do filemove(filename.dds,seperatedir/filename.dds) as the filename can differ per user,only the extension is the same)

Use DirRemove ( "tempcoldboot", 1 ) to remove all the files and folder in that folder Not FileDelete() because this function only deletes files not folders.

coldboot is a file not a folder (it's a file created by the decompression process in the script)

i could do that .. i just need to add DirCreate("Temp") then at the beginning of the script

------

did you download the executable and checked it out... because your answers makes me think you just watched at the script

Edited by kawaiitenshi
Link to comment
Share on other sites

with user interaction i mean that the user doesn't have to do anything after the script starts ( now the user has to edit the loaded file in the hex editor himself ,look for the edited file during the decompression process,choose the extracted.coldboot folder enter original extension,enter new extension,drag and drop dds files onto an exe, remove all files made during the script.)

You should be able to do this by just reading the file(s) into a string with FileRead and then saving it minus the part you want removed by stripping those bits(bytes) out of it with probably something like stringright.

the thing is i need some kind of script that monitors the folder and when all the dds files are created moves them to a seperate folder (i can't do filemove(filename.dds,seperatedir/filename.dds) as the filename can differ per user,only the extension is the same)

Yes you can, just use FileMove(*.dds, <destination dir>*.dds)... instead of specifying each file, it will move all the files with a .dds extension to wherever you're copying them to.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You should be able to do this by just reading the file(s) into a string with FileRead and then saving it minus the part you want removed by stripping those bits(bytes) out of it with probably something like stringright.

can you point me to an example of this ....i never worked with strings before and i'm not sure if it does what i want it to do

small explanation of what the script needs to do:

1. rename Anim_1.jpg to coldboot.raf

2.Move coldboot.raf to Temp folder

3.Delete first 16 bits from coldboot.raf

4.decompress coldboot.raf using zlib decompressor(creates coldboot

5.extract coldboot to extracted.coldboot folder

6.rename *.gim files in extracted.coldboot folder to *.gtf

7.open all files in gtf2dds.exe (must be opened as if dragged on)

this has to be done without a single user interaction (the user should only point to the Anim_1.jpg)

this is what i want to have in the end

Link to comment
Share on other sites

It's a binary file, my suggestion wouldn't work for that.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

It's a binary file, my suggestion wouldn't work for that.

I managed to get the hex edit automated

Run("toolsHex editHexFrame.exe tempcoldboot.raf")
WinWaitActive("Free Hex Editor Neo (Administrator)")
Send("{DEL 8}")
Sleep(2500)
Send("^S")
WinWaitActive("Free Hex Editor Neo (Administrator)")
Send("!{F4}")
Sleep(3000)
WinWaitClose("Free Hex Editor Neo (Administrator)")

thanks for pointing me to the filemove options.. they really helped out :);) ;)

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