tuatara Posted October 27, 2011 Share Posted October 27, 2011 Can anyone help me with this? i am trying to write a script that can copy a directory tree with a unknown number of subdirectories to another disk and: - keep the same tree structure on the new disk - add .old to every file extension found. so picture1.jpg gets picture1.jpg.old and music.mp3 gets music.mp3.old The problem is that my script has to loop very often to rebuild the new directory structure. Thanks for your help. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 27, 2011 Moderators Share Posted October 27, 2011 tuatara,If you download the RecFileListToArray UDF from my sig it becomes very easy: #include <RecFileListToArray.au3> ; Declare paths $sOldPath = "Old_Path" $sNewPath = "New_Path" ; Get list of files within old path $aList = _RecFileListToArray($sOldPath, "*.*", 1, 1, 1) For $i = 1 To $aList[0] ; Copy each of the files to the new path with the added extension - note use of the "8" flag to create the structure if required FileCopy($sOldPath & "\" & $aList[$i], $sNewPath & "\" & $aList[$i] & ".old", 8) NextPlease ask if you have any questions. 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...
tuatara Posted October 27, 2011 Author Share Posted October 27, 2011 Wow, Melba23 i did not expect that, you can't imagine how you helped me, thanks a lot ! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 27, 2011 Moderators Share Posted October 27, 2011 tuatara, Glad I could help. 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...
tuatara Posted October 31, 2011 Author Share Posted October 31, 2011 (edited) Hi Melba23, 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...
tuatara Posted October 31, 2011 Author Share Posted October 31, 2011 Please forget the above, i have made a new topic for this, because it is another problem, hope i did that right 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