Copying files (specifically photos) from a macbook

2019-09-15 15:57发布

Copying files (specifically photos) from a macbook to a USB. Ps. i am new to bash and shell and all that, so a description on how to do it too is very much appreciated (sorry if bad english)

标签: bash shell
1条回答
在下西门庆
2楼-- · 2019-09-15 16:35

Here are some things to get you started...

You can get the mount point of an external, physical drive like this:

diskutil list -plist external physical | plutil -p - | awk -F\" '/"MountPoint"/{print $(NF-1)}'

So, if you want that in a variable do:

usb=$(diskutil ...)
echo $usb 

Sample Output

/Volumes/MUSIC

You can get a list of JPG/jpg/JPEG/jpeg/PNG/png files in the users' HOME directories with:

find /Users -iname \*.jpg -o -iname \*.jpeg -o -iname \*.png

Simplistically, you could now exec cp for each file you find to copy it to your USB drive. However, there are some issues with that - what if you have a file called a.jpg in two different directories - only the second one to be copied will end up on your USB.

find /Users -iname   ...   -exec cp {} "$usb" \;
查看更多
登录 后发表回答