tuatara Posted October 31, 2011 Share Posted October 31, 2011 (edited) Hi guys, Hope you will help me once again. If you connect a Apple computer on a network drive that is also used by windows computers, it creates a lot of annoying .AppleDouble directories. These are hidden for mac users but annoying for Windows users, and can be removed. With your help i created this script: #include <RecFileListToArray.au3> ; Declare paths $sOldPath = @ScriptDir & "\Z-disk" ; ; Get list of directies within this path $aList = _RecFileListToArray($sOldPath, "*.*", 2 , 1 , 1) For $i = 1 To $aList[0] $item = $aList[$i] $aa = $aList[0] ;MsgBox ( 0,"Item is: ", $item) ;MsgBox ( 0,"number of items is: ", $aa) $FullFilePath = $sOldPath & "\" & $item ;MsgBox ( 0,"Dit is FullFilePath: ", $FullFilePath) If StringInStr($FullFilePath,".AppleDouble") Then MsgBox ( 0,"This is a Apple .AppleDouble directory: ", $FullFilePath) DirRemove ($FullFilePath , 1) EndIf Next The script works great when it finds enough directories, but if it doesn't, i get this error: Error: Subscript used with non-Array variable which is a fatal error that crashes the script. Of course i have searched this forum (and Yahoo) but the only thing that seemed to be related was adding FileChangeDir ( ) to scriptdir or to $sOldPath, here and there, but both did not help. The weird thing is, that if i create a small tree with a few .AppleDouble maps in it, the first time i run the script it works great, but after these terrible maps are moved and i fire up the script again, it gives this well known Error: Subscript used with non-Array variable. Any idea's how to prevent this crashes? Thanks, Tuatara Edited October 31, 2011 by tuatara Link to comment Share on other sites More sharing options...
JohnOne Posted October 31, 2011 Share Posted October 31, 2011 Have you tried running the script from scite4autoit? It will show you exactly where the error is produced. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
BrewManNH Posted October 31, 2011 Share Posted October 31, 2011 Try it this way: ; Get list of directies within this path $aList = _RecFileListToArray($sOldPath, "*.*", 2 , 1 , 1) If IsArray($aList) Then For $i = 1 To $aList[0] $item = $aList[$i] $aa = $aList[0] ;MsgBox ( 0,"Item is: ", $item) ;MsgBox ( 0,"number of items is: ", $aa) $FullFilePath = $sOldPath & "\" & $item ;MsgBox ( 0,"Dit is FullFilePath: ", $FullFilePath) If StringInStr($FullFilePath,".AppleDouble") Then MsgBox ( 0,"This is a Apple .AppleDouble directory: ",$FullFilePath) DirRemove ($FullFilePath , 1) EndIf Next EndIf 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 Link to comment Share on other sites More sharing options...
tuatara Posted October 31, 2011 Author Share Posted October 31, 2011 Dear BrewManNH you have solved it !!! Thanks a lot ! -------- 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