Skip to content

Instantly share code, notes, and snippets.

@lahwaacz
Last active December 14, 2015 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lahwaacz/5157089 to your computer and use it in GitHub Desktop.
Save lahwaacz/5157089 to your computer and use it in GitHub Desktop.
zsh function to 'safe' copy to FAT32 partition
#! /bin/zsh
# Inspired by:
# http://askubuntu.com/questions/11634/how-can-i-substitute-colons-when-i-rsync-on-a-usb-key
autoload zargs zmv
fatcp() {
local src="$1"
local dest="$2"
local replace='<>|;:!?"*\+'
replace=${(q)replace}
zmv -C -Q -v -p mkdir -o -p $src/'(**/)(/)' $dest/${src:t}/'${1//[$replace]/_}'
zmv -C -Q -v -o -pu $src/'(**/)(*)(.)' $dest/${src:t}/'${1//[$replace]/_}${2//[$replace]/_}'
}
fatcp "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment