Moderators Melba23 Posted January 6, 2013 Moderators Share Posted January 6, 2013 sparker366,The path "#:worktempword1 word2 word3 - 1" works fine for me when I create it and then use my UDF - and this whether I list the content from the full path or recur into it from a higher level. Are you sure that the actual path does not have some wacky characters instead of 0x20? M23 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...
sparker366 Posted January 6, 2013 Author Share Posted January 6, 2013 (edited) Its just spaces. Does it list the files inside it when you run your UDF? When I run it tells me those 2 errors and then exits nothing is displayed. I renamed the directory to that name. Let me create a fresh directory and try it. Created a fresh directory removed the include statement from the UDF call and it still gives me a 1 1 error and displays nothing. Edited January 6, 2013 by sparker366 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2013 Moderators Share Posted January 6, 2013 sparker366,Does it list the files inside it when you run your UDF?That is what "works fine" usually means. What line of code are you using with the UDF to read the files? M23 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...
sparker366 Posted January 6, 2013 Author Share Posted January 6, 2013 This is the code #comments-start This script will take path passed to it from the commandline then go to that directory and Delete any files other then a video and a nfo file. #comments-end #include <RecFileListToArray.au3> #include <Array.au3> Global $iReturnValue Local $path = $CMDLINE[1] Local $sample = $path & "\sample" MsgBox(0, "Deletion", $path, 5) If FileExists($sample) Then DirRemove($sample, 1) Else MsgBox(4096, "Does NOT exists", $sample, 5) EndIf FileChangeDir($path) $aArray = _RecFileListToArray($path, "*.url; *.txt; *.sfv; *.nzb") $err = @error & " " & @extended MsgBox(0, "Errors", $err) _ArrayDisplay($aArray, "Files") That is the full code of the small script. I do test for a sample dir in there and if there is one delete it. I then call the UDF after changing to the directory I want to work on. If I pass it a directory without spaces in the name it works fine for me. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2013 Moderators Share Posted January 6, 2013 sparker366,Are you sure you are getting the full path in $CMDLINE[1]? If I pass the path without enclosing quotes I only get "#:worktempword1" passed to the script - which will obviously fail. I see you are checking with a MsgBox - does it show the whole path? Apologies if that sounds too obvious, but I am confused as to why you cannot get the UDF to work. One final question - did you copy/paste the code from the UDF post itself or did you download the zip file? The forum software is notorious for occasionally stripping backslashes and other important characters from posted code - the version in the zip file is defintiely not corrupted as I checked it a few days ago. M23 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...
sparker366 Posted January 6, 2013 Author Share Posted January 6, 2013 (edited) I downloaded the file from your sig. No copy and pasting then saving. Its getting truncated only word1 shows up. I am passing it without quotes in my dos window. When I put double quotes around it it worked fine. I was unaware of that. Sorry. So only from a dos window do I need to use the double quotes. When its passed from the program it should be fine. Ok this was all my fault not knowing about passing it with double quotes. So when I passed it without double quotes the path was getting truncated thus failing. So am I to assume that the cmdline[0] will have a full path and not get truncated if the path has spaces in it? Would it still be best to read the path see if it has spaces and then replace the space rename the directory and then proceed. I figured out how to replace the spaces in it now I just have to figure out how rename the directory. There doesn't appear to be any rename command. So I guess I will have to create a new directory and move the old directory to the new directory then remove the old directory and be done with it. This way I am sure there will be no issues what so ever. Edited January 6, 2013 by sparker366 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2013 Moderators Share Posted January 6, 2013 sparker366,Well at least we found the problem. $CMDLINE[0] gives you the number of parameters - $CMDLINERAW gives you the full command line, but it is best to use quotes to surround any DOS path just in case you have spaces. If you want to remove the spaces to prevent any possible future problem, you need to use DirMove - as the Help file explains:"Because AutoIt lacks a "DirRename" function, use DirMove to rename a folder!"Glad we got there in the end. M23 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...
sparker366 Posted January 6, 2013 Author Share Posted January 6, 2013 I thank you so much for all your help. On the directory move If I assign cmdline[1] to $path and do this $path2 = StringRegExpReplace($path, " ", "_") Then use DirMove to move the contents of $path to $path2. Will $path2 get created with the DirMove function? I am assuming that $path will no longer exist when the DirMove function is used or do I have to follow up with a DirRemove call? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2013 Moderators Share Posted January 6, 2013 sparker366,A simple StringReplace($path, " ", "_") should do the trick - no need for a RegEx. As to the second question: why would the destination folder not be created when you use DirMove - and what would you expect to happen to the source folder? M23 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...
sparker366 Posted January 6, 2013 Author Share Posted January 6, 2013 Ok that seems alot simpler no need to create other variables that are not needed. What happens if there are no spaces with the StringReplace function will it gracefully exit and not error out As for my second question the help file didn't give any indication if the directory didn't exits what would happen. I thought it would get created but wasn't 100% sure. Now on the move again was unsure as the help file didn't give any indication about that either I am getting more familiar as I progress. I guess what I need to do is create simple scripts to test out things then I can implement that into my larger script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2013 Moderators Share Posted January 6, 2013 sparker366,What happens if there are no spaces with the StringReplace function will it gracefully exit and not error outMay I refer you to your final phrase:I guess what I need to do is create simple scripts to test out things then I can implement that into my larger scriptEnough said? M23 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...
sparker366 Posted January 6, 2013 Author Share Posted January 6, 2013 Well after some errors on my part I got this figured out and am on my way to creating the script that I need to clean up directories. I am going to move all my current scripts out of my work directory and start clean so I have a clean slate with no issues. I guess the next thing I can learn is to recurse it through the directories and clean all the folders up instead of going from here forward. But that will have to wait to i get more familiar with Autoit. Which is by the way a great tool. Link to comment Share on other sites More sharing options...
AZJIO Posted January 6, 2013 Share Posted January 6, 2013 sparker366,_FO_FileDirReName My other projects or all Link to comment Share on other sites More sharing options...
sparker366 Posted January 7, 2013 Author Share Posted January 7, 2013 I have one more question. I did get it work correctly and ran it though about 10 directories and it worked fine but I did run it through 2 directories that had a file or 2 that wasn't in my list. Since that could be the unknown aspect of the equation I figured I might as well use an exclude list instead. After doing some testing to test I wanted to modify my call to your UDF use an exclude list instead of an include list. I know the directories will contain video files a possible image and one other file "*.avi, *.wmv, *.mpg, *.mp4, *.mov, *.mkv, *.flv, *.nfo, *.jpg, *.gif, *.png" What I am unsure of is what files I don't want. So I thought if I build the array with an exclude list that would give me all the files I wanted to delete Local $FileList = _RecFileListToArray($path2, "*|*.mp4; *.avi; *.mpg; *.wmv; *.flv,*.mov,*.mkv, *.jpg, *.png, *.gif, *.nfo"). I used the above and got no errors looking at folders that didn't contain any of the excluded files and did contain those files.I am wanting to know if this is the best way to do it. That list of files in the above line is what I want to keep everything else I want to get rid of. So if I did the UDF call correctly it will include all files but also exclude those files after it. Thus the resultant created array will just have the files I wanted to delete. Is this the best way to do it? My other thought was to create an ini file with these file types in and read that into the script and then pass that variable to your UDF. Can that be done? The reason behind the ini file is to make the code look nicer and also be able to store different lists of files I wanted to process. I could then concatenate the variable based on what i wanted to do whether it include or exclude files. Maybe I am over thinking this but again maybe I am not. I just want to get rid of these files in an easy way. Again thanks for all the help you gave me yesterday Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 7, 2013 Moderators Share Posted January 7, 2013 sparker366,What you are doing with the exclude list looks fine to me - the UDF should return the files in the folder which do not match those extensions so you can loop through the array to delete them. But be careful - you are more often using "," as a delimiter in that snippet instead of the correct ";". As to the ini file idea - it should be pretty easy to do as you could put different lists into different sections. The Ini* functions can get the section names and then values into arrays with no effort. Once you have them a quick loop to concatenate them will produce a variable to pass to the UDF. Give it a go and see how you get on - you know where I am if you run into difficulties. M23 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...
sparker366 Posted January 7, 2013 Author Share Posted January 7, 2013 (edited) Yeah I saw at the end of that list I messed up and didn't use the correct delimiter. I since fixed that. This is my new code. #include <RecFileListToArray.au3> #include <Array.au3> $path = Local $path = $CMDLINE[1] $exclude = "*.*|*.mp4; *.avi; *.mpg; *.wmv; *.flv; *.mkv; *.mov; *.jpg; *.png; *.gif; *.nfo" FileChangeDir($path) Local $FileList = _RecFileListToArray($path, $exclude, 1, 1, 1, 2) MsgBox(0, "Files include", @error & " " & @extended) _ArrayDisplay($FileList) I set a variable and passed it to your UDF to make things neater and to try it. It worked. Now I have a list of files that I can delete. I had set the first switch to 2 and it gave me some wonky results which probably is expected. I then switched it to 1 and it gave me a list of correct results. So that list I can pass to my delete routine and get rid of all the files. I am plagued by typos and need to look closer at my code. LOL I guess my fingers go faster then my brain or my brain goes faster then my fingers and I make typos. Most of my errors are caused by typos. Again thanks much I will mess with the ini concept at a later point. Just using the variable in the code makes thing neater imo. Edited January 7, 2013 by sparker366 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 7, 2013 Moderators Share Posted January 7, 2013 sparker366,I am plagued by typosI suggest you download and install the full SciTE4AutoIt3 package you can find here. Then when you run/compile your scripts you automatically run a couple of check apps (Tidy and AU3Check) which look for simple errors such as mistyped variables, incomplete structures, etc. You also get a whole heap of other helpful things - expandable abbreviations, tooltips for function parameters, and lots more. Most experienced AutoIt coders would not be without it. M23 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...
sparker366 Posted January 7, 2013 Author Share Posted January 7, 2013 I do have the full package I do believe. I can redownload the full package and install it and see if it helps. I am not at this time compiling my scripts am just running them as .au3 files. So compiling them will do some error checking for me. What other benefit does compiling give me? i did download the full editor as I must have installed a different one as my help wasn't working. I got that fixed. Link to comment Share on other sites More sharing options...
BrewManNH Posted January 7, 2013 Share Posted January 7, 2013 (edited) Compiling shouldn't affect the error checking done by Au3Check, it probably just runs that before compiling. You should do that on your script prior to running it anyways (CTRL-F5) just to be sure you haven't got any of the issues that it can prevent. Edited January 7, 2013 by BrewManNH 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...
Moderators Melba23 Posted January 7, 2013 Moderators Share Posted January 7, 2013 (edited) sparker366, If you have the full editor then you will get the checks both on running and compiling - you should see something like this in the SciTE console: >"M:\Program\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "M:\Program\Au3 Scripts\Test.au3" /UserParams +>16:10:48 Starting AutoIt3Wrapper v.2.1.0.43 Environment(Language:0409 Keyboard:00000809 OS:WIN_VISTA/Service Pack 2 CPU:X64 OS:X86) >Running AU3Check (3.3.9.4) from:M:\Program\AutoIt3\beta +>16:10:48 AU3Check ended.rc:0 >Running:(3.3.9.4):M:\Program\AutoIt3\beta\autoit3.exe "M:\Program\Au3 Scripts\Test.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop +>16:10:48 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 1.656 It is AutoIt3Wrapper that does all the magic. M23 Edited January 7, 2013 by Melba23 Typo 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...
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