Last active
December 14, 2015 22:18
-
-
Save lahwaacz/5157089 to your computer and use it in GitHub Desktop.
zsh function to 'safe' copy to FAT32 partition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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