Sign in to follow this  
Followers 0
tuatara

copy a tree and change every file extention

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



tuatara,

If you download the RecFileListToArray UDF from my sig it becomes very easy: :oops:

#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)
Next

Please ask if you have any questions. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Wow, Melba23 i did not expect that, you can't imagine how you helped me,

thanks a lot !

Share this post


Link to post
Share on other sites

tuatara,

Glad I could help. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by tuatara

Share this post


Link to post
Share on other sites

Please forget the above, i have made a new topic for this, because it is another problem,

hope i did that right

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0