{"id":17063762,"url":"https://github.com/atapas/add-copyright","last_synced_at":"2025-04-12T18:14:36.956Z","repository":{"id":47266894,"uuid":"256401215","full_name":"atapas/add-copyright","owner":"atapas","description":"This is a Script to Automate adding the Copyright text to one or more source files Recursively. ","archived":false,"fork":false,"pushed_at":"2023-01-27T21:49:43.000Z","size":65,"stargazers_count":82,"open_issues_count":5,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T18:14:13.562Z","etag":null,"topics":["add-copyright","automation","bash","bash-script","copyright","hacktoberfest","license","script"],"latest_commit_sha":null,"homepage":"https://blog.greenroots.info/add-copyright-or-license-text-to-the-source-files-recursively-ck93zodue042h7us1nur56u4f","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atapas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["atapas"]}},"created_at":"2020-04-17T04:29:21.000Z","updated_at":"2025-01-05T00:26:37.000Z","dependencies_parsed_at":"2023-02-15T13:00:52.057Z","dependency_job_id":null,"html_url":"https://github.com/atapas/add-copyright","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atapas%2Fadd-copyright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atapas%2Fadd-copyright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atapas%2Fadd-copyright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atapas%2Fadd-copyright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atapas","download_url":"https://codeload.github.com/atapas/add-copyright/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248610336,"owners_count":21132920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["add-copyright","automation","bash","bash-script","copyright","hacktoberfest","license","script"],"created_at":"2024-10-14T10:52:59.382Z","updated_at":"2025-04-12T18:14:36.929Z","avatar_url":"https://github.com/atapas.png","language":"JavaScript","funding_links":["https://github.com/sponsors/atapas"],"categories":[],"sub_categories":[],"readme":"# add-copyright\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fatapas%2Fadd-copyright.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fatapas%2Fadd-copyright?ref=badge_shield)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\nThis is a **Script to Automate** adding the Copyright text to one or more source files **Recursively**. The Copyright texts get added to the top of the source file. Ice on the Cake is, it doesn't duplicate the copyright text if it is added already!\n\nNote: The same tool can be used to add any such text blocks like, License, File level Comments etc.\n\nHere is an example of JavaScript(.js) file.\n\n```js\n\n/*\n © Copyright 2020 tapasadhikary.com or one of its affiliates.\n * Some Sample Copyright Text Line\n * Some Sample Copyright Text Line\n * Some Sample Copyright Text Line\n * Some Sample Copyright Text Line\n * Some Sample Copyright Text Line\n * Some Sample Copyright Text Line\n*/\n\nconst test = () =\u003e {\n\tconsole.log('test');\n}\n\ntest();\n```\n\n# To Run this on your Source Code\n\n- Clone the project. This project comes with a script file called `addcopyright.sh` and few test files to test out things before you feel comfortable to try it on your source code.\n- Browse to the folder where you have cloned the project.\n- Change directory to `add-copyright` folder.\n- Open a shell or Gitbash or any unix command supported prompt.\n- Execute this command:\n  ```bash\n   export COPYRIGHTLEN=`wc -l copyright.txt | cut -f1 -d ' '`\n  ```\n  The above command will set some variable value that will be used by the `addcopyright.sh` script.\n- Execute the following command to add the copyright/license text from the `copyright.txt` to your source code:\n  ```bash\n   find \u003cSOURCE_CODE_DIRECTIRY\u003e -type d -name \"\u003cEXCLUDE_DIRECTORY\u003e\" -prune -o -name \"*.js\" -print0 | xargs -0 ./addcopyright.sh\n  ```\n  Where the `\u003cSOURCE_CODE_DIRECTIRY\u003e` is the path of your source code.\n  Where the `\u003cEXCLUDE_DIRECTORY\u003e` is the directory to exclude if it exists under `\u003cSOURCE_CODE_DIRECTIRY\u003e` for updating the Copyright information.\n\n# Usage\nMake sure you have given the execute permission to the `addcopyright.sh` script file. You can provide the permission using following command:\n\n```bash\nchmod +x addcopyright.sh\n```\nIf your user is not having root privileges, add your $USER to 'roots' group using command :\n```bash\nuseradd -m -G root $USER\n```\nAlternatively: \u003cbr/\u003e\nInsert 'sudo' when executing the run command. For example:\n```bash\n sudo find \u003cSOURCE_CODE_DIRECTIRY\u003e -type d -name \"\u003cEXCLUDE_DIRECTORY\u003e\" -prune -o -name \"*.js\" -print0 | sudo xargs -0 ./addcopyright.sh\n```\n## Running it on Source Code without any Exclusions\nFor running the tool on the Source code without excluding any folders, use this command:\n\n```bash\nfind \u003cSOURCE_CODE_DIRECTIRY\u003e  -name \"*.js\" -print0 | xargs -0 ./addcopyright.sh\n```\n- For current directory use `.`(dot)\n- If your source code is in `/home/atapas/code` directory, use the above command as,\n  ```bash\n    find \u003cSOURCE_CODE_DIRECTIRY\u003e  -name \"*.js\" -print0 | xargs -0 ./addcopyright.sh\n  ```\n  \n## Running it on Source Code with Exclusions(Say, node_modules)\nFor Running the tool on the Source Code by excluding the folder of your desire(say, node_modules for nodeJs based applications), use this command:\n\n  ```bash\n   find /opt/atapas/code -type d -name \"node_modules\" -prune -o -name \"*.js\" -print0 | xargs -0 ./addcopyright.sh\n  ```\n### Excluding multiple directories(Say, node_modules and test)\nIf your source code is in `/home/atapas/code` and want to exclude `node_modules` and `test` directories, use the above command as,\n     \n  ```bash\n     find /opt/atapas/code -type d -name \"node_modules\" -prune -o -type d -name \"test\" -prune -o -name \"*.js\" -print0 | xargs -0 ./addcopyright.sh\n  ```\n\n## Change the file Types\nTo Change the file type, just replace the `*.js` with any other extentions like, `*.java`, `*.cpp` etc.\n\n# Limitations\n\n- This tool can only be run from a Linux Bash Shell. For running it from windows use any bash shell like [GitBash](https://git-scm.com/download/win).\n- This tool can be made use for different language files like javascript, java, c, c++, html, shell-script etc. However the content of the `copyright.txt` should be changed according to the mult-line comment format. For example,\n\n  For Javascript(.js) or Java(.java) files this is the format:\n \n  ```js\n\t  \n   /*\n    This is a comment\n   */\n   ```\n  \n  For HTML(.htm or .html) file the format should be,\n  \n  ```html\n\t  \n  \u003c!-- \n     This is a HTML Comment\n  --\u003e\n  ```\n  \n## Credit\n\nThe soution was found as part of this discussion on the StackOverflow and keep improving thereafter!\n\n- https://stackoverflow.com/questions/151677/tool-for-adding-license-headers-to-source-files\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/IAMLEGION98\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/20149005?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eIAMLEGION98\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/atapas/add-copyright/commits?author=IAMLEGION98\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://tapasadhikary.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/3633137?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eTapas Adhikary\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/atapas/add-copyright/commits?author=atapas\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/prepaka\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/38240616?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ePradeep Repaka\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/atapas/add-copyright/commits?author=prepaka\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fatapas%2Fadd-copyright.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fatapas%2Fadd-copyright?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatapas%2Fadd-copyright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatapas%2Fadd-copyright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatapas%2Fadd-copyright/lists"}