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)
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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" \;