Italiano Posted March 26, 2016 Share Posted March 26, 2016 Hello... as title says... is there a method that I can use in Autoit to restore single files from recycle bin? If I am right, there is just a command to empty it (filerecycleempty). Since I was planning to add a simple "undo" in a script that i am writing to restore files that the script deletes, i was wondering if i could restore them directly with autoit. Any ideas? Sorry for my bad english and sorry if it exists already a function for it and i was not good to find it thx Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2016 Moderators Share Posted March 26, 2016 (edited) Italiano, I use this code from Yashied to enumerate the contents of the Recycle bin. Once you have the list, you can use FileMove to move the file as shown: expandcollapse popup#Include <Array.au3> Func _EnumRecycleBinItems($sRoot = '') Local $oShellApp, $oRecycleBin, $oFolderItems, $oItem $oShellApp = ObjCreate('Shell.Application') $oRecycleBin = $oShellApp.NameSpace(10) If Not IsObj($oRecycleBin) Then Return SetError(1, 0, 0) EndIf Local $Ret, $Result[101][6] = [[0]] $sRoot = StringStripWS($sRoot, 3) If $sRoot > '' Then If StringInStr($sRoot, ':') Then $sRoot = StringRegExpReplace($sRoot, ':.*', '') Else $sRoot = '' EndIf If Not FileExists($sRoot & ':') Then Return SetError(1, 0, 0) EndIf EndIf $Ret = DllCall('shell32.dll', 'none', 'SHGetSettings', 'uint*', 0, 'dword', 2) If @error Then Return SetError(1, 0, 0) EndIf $oFolderItems = $oRecycleBin.Items() For $oItem In $oFolderItems If ($sRoot > '') And ($sRoot <> StringLeft($oItem.Path, 1)) Then ContinueLoop EndIf $Result[0][0] += 1 If $Result[0][0] > UBound($Result) - 1 Then ReDim $Result[$Result[0][0] + 100][UBound($Result, 2)] EndIf $Result[$Result[0][0]][0] = $oRecycleBin.GetDetailsOf($oItem, 0) ; Original name $Result[$Result[0][0]][1] = $oRecycleBin.GetDetailsOf($oItem, 1) ; Original path $Result[$Result[0][0]][2] = $oRecycleBin.GetDetailsOf($oItem, 2) ; Deleted date ; $Result[$Result[0][0]][3] = $oRecycleBin.GetDetailsOf($oItem, 3) ; Size $Result[$Result[0][0]][3] = $oItem.Size ; Size $Result[$Result[0][0]][4] = FileGetAttrib($oItem.Path) ; Attributes $Result[$Result[0][0]][5] = $oItem.Path ; Recycle name If (Not $Ret[1]) And (Not StringInStr($Result[$Result[0][0]][4], 'D')) Then If StringInStr($Result[$Result[0][0]][5], '.') Then $Result[$Result[0][0]][0] &= StringRegExpReplace($Result[$Result[0][0]][5], '^.*\.', '.') EndIf EndIf Next ReDim $Result[$Result[0][0] + 1][UBound($Result, 2)] Return $Result EndFunc ;==>_EnumRecycleBinItems $Data = _EnumRecycleBinItems() _ArrayDisplay($Data) ; To recover a file all you need do is: FileMove($Data[1][5], $Data[1][0]) ; Recovers the first file in the list M23 Edited March 26, 2016 by Melba23 Fixed text formatting Xandy 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Italiano Posted March 26, 2016 Author Share Posted March 26, 2016 Very much appreciated, thank you a lot! I will play with your code Link to comment Share on other sites More sharing options...
stasia8954 Posted April 17, 2016 Share Posted April 17, 2016 (edited) Quote I use this code from Yashied to restore the contents of the Recycle bin. Once you have the list, you can use FileMove to move the file as shown: Does this script works on Windows 10? Edited April 23, 2016 by stasia8954 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 17, 2016 Moderators Share Posted April 17, 2016 @stasia8954, it would probably have taken you less time to actually try it than it did to write your post. Have you tried it for yourself? Are you experiencing issues? If so, instead of just a blanket "is this supposed to work" question, try explaining in detail what problems you're running into. Earthshine 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Yanccery Posted August 9, 2017 Share Posted August 9, 2017 (edited) On 2016/3/26 at 11:18 PM, Melba23 said: Italian, I use this code from Yashied to enumerate the contents of the Recycle bin. Once you have the list, you can read : https://www.tunesbro.com/recover-deleted-contats-from-iphone-without-backup.html I want to know , if there is a time limit ,i accidentally lost data last month , up to now , those data have not been recovered back , i am not sure whether your method will help me recover back them , Edited August 17, 2017 by Yanccery Link to comment Share on other sites More sharing options...
Simpel Posted August 9, 2017 Share Posted August 9, 2017 (edited) Hi. This script shows only the files which are currently in the recycle bin. They can lay there for years if you don't empty your recycle bin. If you look manually into your recycle bin and the file is in there the script will work. But I guess you have emptied your recycle bin and now looking for a solution to restore your burned files? This script isn't about that. Regards, Conrad Edited September 26, 2017 by Simpel Typo SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
Shehab0 Posted September 26, 2017 Share Posted September 26, 2017 (edited) On 2017/8/9 at 4:27 PM, Yanccery said: I want to know , if there is a time limit ,i accidentally lost data last month , up to now , those data have not been recovered back , i am not sure whether your method will help me recover back them , Must have been overwritten by new data, if you lost data, you can only get them back with a recovery tool as soon as possible. Edited January 11, 2018 by Shehab0 Link to comment Share on other sites More sharing options...
Naklsder Posted December 8, 2017 Share Posted December 8, 2017 (edited) On 2017/8/9 at 4:27 PM, Yanccery said: I want to know , if there is a time limit ,i accidentally lost data last month , up to now , those data have not been recovered back , i am not sure whether your method will help me recover back them , http://www.mobiledic.com/android-data-rescuer.html On 2017/9/26 at 4:11 PM, Shehab0 said: Must have been overwritten by new data, if you lost data, you can only get them back with a recovery tool as soon as possible. It hard to say , there are no chance ,once the data is overwritten ,they are completely erased from memory card or other device , Edited December 11, 2017 by Naklsder Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now