Skip to content

Instantly share code, notes, and snippets.

@ciscorucinski
Last active August 24, 2017 16:46
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 ciscorucinski/c573139ccf15cb8f06458b07025dfd07 to your computer and use it in GitHub Desktop.
Save ciscorucinski/c573139ccf15cb8f06458b07025dfd07 to your computer and use it in GitHub Desktop.
task ChroMATERIAL_RenameFiles(type: Copy) {
String sourceDir = 'src/colors'
String XML = '.xml' // Extension to keep
String ICLS = '.icls' // Extension to remove
// "Copy" files into the same directory.
from sourceDir
destinationDir file(sourceDir)
String fileName
rename { String file ->
// Only delete the xml file of the associated icls files that are present in the directory
if (file.contains(ICLS)) {
fileName = file.replace(ICLS, '')
delete fileName.concat(XML)
}
// Rename all icls file extensions to be xml files
file.replace(ICLS, XML)
}
// Lastly, delete all remaining icls files from the directory
doLast {
delete fileTree(sourceDir) {
include('**/*'.concat(ICLS))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment