yaredou Posted October 4, 2010 Share Posted October 4, 2010 Hello folks, I'm writing a script to go through a list of files, check the date, if older than a week, move them to a folder named with the file date as YYYY-MM-DD. It is necessary for the folder name to contained hyphens to follow convention. I'm running into a problem with the DirCreate function however in that it will not create the folder if the name contains hyphens. Below is the part of my code that deals with the files. Any ideas? Thanks much, ; set working directory for moving files $dir_m = "\\10.10.20.21\c$\Daily" FileChangeDir($dir_m) dim $dirpath ;Find Old version of files $FileList=_FileListToArray($dir_m) If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf _ArrayDisplay($FileList,"$FileList") ;For/Next loop to step through the array: For $n = 1 To $FileList[0] ; [0] = line count $fileinfo = FileGetTime ($FileList[$n]) ;MsgBox (0, "Filedate", $fileinfo[0] & "/" & $fileinfo[1] & "/" & $fileinfo[2] ) $Filedate = $fileinfo[0] & "/" & $fileinfo[1] & "/" & $fileinfo[2] $FileAge = _DateDiff ('w', $Filedate, _NowCalc()) ; Determine if file is older than 1 week old - 'w' flag indicates week If $FileAge >= 1 Then ; If older than one week move to the appropriate folder - create if doesn't exist $hyp = "-" $dirpath = $fileinfo[0] & "-" & $fileinfo[1] & "-" & $fileinfo[2] ;msgbox (0, "move this file", $FileList[$n]) ;DirCreate ($dir_m & "\" & $dirpath) ;DirCreate ($dir_m & "\" & "test-1") ;DirCreate ($dir_m & "\" & $fileinfo[0] & $hyp & $fileinfo[1] & $hyp & $fileinfo[2]) ;FileMove ($FileList[$n], $dir_m & "\" & $dirpath, 8) EndIf ;MsgBox(64, "Current file:", $FileList[$n]) Next Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 4, 2010 Moderators Share Posted October 4, 2010 yaredou,DirCreate creates folders with hyphenated names without problem - I have just run your code and it created hyphenated folders in the base folder for all files older than a week. Do you have the necessary permissions to create the folders? 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...
yaredou Posted October 4, 2010 Author Share Posted October 4, 2010 M23, right again. The permissions were ok, what happened is that a previous faulty execution of the program created extension-less files that the code mistook for folders. After deleting these files, the folders were created without a problem. I appreciate your prompt response! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 4, 2010 Moderators Share Posted October 4, 2010 yaredou, We try to please! 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...
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