Script to find file by extension and Copy it to SMB Share retaining Folder Structure

Chris_Lyons
New Contributor

Hello,

I am looking to create a script that finds a particular file by its extension across the entire drive including all users folders. Then it will need to mount an smb share, create a folder named after the computer name within that should be the files found but they need to be in a folder structure that matches the file path.

I also would need to have the script save a log to a Log folder on the top level of the smb share labeled the Computer Name.

I am not sure what I would need to combine to make this happen, if anyone has any suggestions or samples that would be a great help.

This is what is used now to find files with the ".nsf" extension:

mdfind -name 'kMDItemKind == "Notes database file" && kMDItemFSName == "*.nsf"'

/Users/cxlyons/Library/Application Support/IBM Notes Data/log.nsf
/Users/cxlyons/Library/Application Support/IBM Notes Data/names.nsf
/Users/cxlyons/Library/Application Support/IBM Notes Data/bookmark.nsf
/Users/cxlyons/Desktop/ScripttoCopy/bookmark.nsf

The script would find the files use the path to create the necessary folder structure inside a parent folder named after the Computer name. also saving a log of what was copied to a folder on the top level of the share called "Log Files" with the name of the computer for file name.

I don't know what would be the best solution for this script.

We are moving from Lotus Notes to Outlook these files will be converted at a later date.

Thanks
Chris Lyons

1 REPLY 1

bpavlov
Honored Contributor

What scripting languages do you know? That would be the best place to start since it would be something you're familiar with...

If you can use the command line then its as simple as copying that over into a shell script. Give it a try and see what you come up with.
And congrats on the move away from Notes!