Last active
August 29, 2015 14:13
-
-
Save stephanb/3f02636bcf1fe9300b89 to your computer and use it in GitHub Desktop.
Rename and copy/move all files or directories matching a pattern
This file contains hidden or 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
| find . -type f -name "*your-pattern*" | while read oldname; do newname=`echo $oldname | sed 's/your-pattern/substitute-value/g'`; cp $oldname $newname; done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This command:
your-patternin their filenames in the current directory and its sub-directoriesyour-patternwithsubstitute-valuein the filenameReplace
your-patternandsubstitute-valuewith your own values.If you want to rename the file rather than copy it, replace the command
cpwithmv.If you want to work with directories only, use
-type dinstead of-type f.