Hello guys, i am new to applescript and I think what i want to accomplish is faily easy.
This is what I want to do.
I want an applescript to get File1 and copy it to each subfolder of a subfolder in Folder1. If there is a file of the same name in the folders, I want them to be replaced. Folder1 will be growing and will have more subfolders inside which is the reason why I want this to be done automatically.
This is fairly simple to do with a recursive script. This should get you going:
set theFile to "path:to:original:file"
set theTopFolder to "path:to:top:folder:"
on copyTheFileTo(destDir)
tell application "Finder"
duplicate file theFile to folder destDir
set subFolders to every folder of destDir
repeat with eachSub in subFolders
tell me to copyTheFileTo(subDir)
end repeat
end tell
end copyTheFileTo
copyTheFileTo(theTopFolder)
The idea here is that you get the path to the file and a starting directory. The ‘copyTheFileTo’ handler first copies the file into that directory, then walks through any subdirectories calling itself for each subdirectory. For each subdirectory it copies the file into it and looks for any more subdirectories. At the end, every directory under theTopFolder will have the file in it.
You may need to adjust the ‘duplicate’ command to deal with existing files, etc.