Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Half OT: Convenient way to a copy with path of single files



On Sep 24,  7:09am, meino.cramer@xxxxxx wrote:
}
}     mycp /home/user/A/B/C/D/files.txt /home/A/B/other/.
} 
} results in :
} 
}    /home/A/B/other/C/D/files.txt

Something along these lines should work:

autoload -Uz zmv
zmv -C '/(home)/user/(A)/(B)/(C)/(D)/(files.txt)' '/$1/$2/$3/other/$4/$5/$6'

Unfortunately that doesn't translate well to replacing "files.txt" with
an arbitrary subtree pattern, because parenthesized glob patterns can
only refer to files within a single directory.

However, the special case of a recursive glob will work if you make use
of the -w option:

zmv -wC '/(home)/user/(A)/(B)/(C)/(D)/**/*(.txt)' '/$1/$2/$3/other/$4/$5$6$7'

Here $5 contains everything found by **/ _including_ the trailing slash,
and $7 contains the .txt extension; hence no slashes in $5$6$7.



Messages sorted by: Reverse Date, Date, Thread, Author