wth Posted November 19, 2010 Posted November 19, 2010 Hi There, I've written this script but FileDelete isn't working all of the time. Today, 2 out of 10 were deleted. All of the files it is trying to delete it has access to. The filegetattrib only return "A" for those it cannot delete. All of the files are created at the same time through excel about 7 hours ago. expandcollapse popup_main() Func _main() Local $sPOFolder Local $aFilelist Local $i Local $cProgressBar Local $aIndices[2] $cProgressBar = ProgressOn("Copy Retail Text Files", "", "", 0, @DesktopHeight - 200) ProgressSet(0, "", "Starting copy files") If $cmdline[1] = "CFC" Then $sPOFolder = $sPACCRootCFC & "daily_po\" ElseIf $cmdline[1] = "SFC" Then $sPOFolder = $sPACCRootSFC & "daily_po\" EndIf $aFilelist = _FileListToArray($sPOFolder, $cmdline[2] & "*.txt") _ArrayDelete($aFilelist, 0) ProgressSet(0,"Files 0 of " & UBound($aFilelist) & " completed", "0 of " & UBound($aFilelist)) For $i = 0 to UBound($aFilelist) - 1 If Not $aFilelist[$i] = "" Then $sDestFolder = _getDestFolder($aFilelist[$i], $cmdline[1]) ProgressSet(Int(($i+1)/UBound($aFilelist)*100), "Copying " & $aFilelist[$i] & " to " &@CRLF& $sDestFolder &@CRLF& $aFilelist[$i], $i+1 & " of " & UBound($aFilelist)) FileCopy($sPOFolder & $aFilelist[$i], $sDestFolder & $aFilelist[$i], 1) Sleep(2000) If FileExists($sDestFolder & $aFilelist[$i]) Then ProgressSet(Int(($i+1)/UBound($aFilelist)*100), "Deleting " & $aFilelist[$i], $i+1 & " of " & UBound($aFilelist)) FileDelete($sPOFolder & $aFilelist[$i]) If @error = 0 Then MsgBox(0,"Error: " & @error, "This file was not deleted" &@CRLF& "File attributes are: " & FileGetAttrib($sPOFolder&$aFilelist[$i])) EndIf Else MsgBox(0,"File not copied!!!", $aFilelist[$i] & " was not copied. Please report this error and verify that the file was in fact not copied.") EndIf EndIf Next ProgressOff() EndFunc I left out the _getdestfolder and global variables. They are all or return folder paths with a \ at the end. Any suggestions? Thanks,
BrewManNH Posted November 19, 2010 Posted November 19, 2010 If the files are locked, maybe still in use, you can't delete them. 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 GudeHow 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
wth Posted November 19, 2010 Author Posted November 19, 2010 Absolutely Correct! It took me longer to create that post then it did for you to tell me what I did wrong. ) Thanks!
BrewManNH Posted November 19, 2010 Posted November 19, 2010 At least it was that easy to fix 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 GudeHow 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
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