{"id":18091264,"url":"https://github.com/dfsp-spirit/tmp_change_file_ext","last_synced_at":"2026-05-17T18:04:59.935Z","repository":{"id":98535444,"uuid":"115142019","full_name":"dfsp-spirit/tmp_change_file_ext","owner":"dfsp-spirit","description":"Bash script to temporarily rename files with specific file extensions, and revert to the original ones later.","archived":false,"fork":false,"pushed_at":"2017-12-25T02:11:44.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-06T02:42:47.363Z","etag":null,"topics":["bash","infrastructure","shell","tools"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dfsp-spirit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-22T18:49:13.000Z","updated_at":"2022-02-15T22:00:35.000Z","dependencies_parsed_at":"2023-05-29T09:15:18.387Z","dependency_job_id":null,"html_url":"https://github.com/dfsp-spirit/tmp_change_file_ext","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dfsp-spirit/tmp_change_file_ext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfsp-spirit%2Ftmp_change_file_ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfsp-spirit%2Ftmp_change_file_ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfsp-spirit%2Ftmp_change_file_ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfsp-spirit%2Ftmp_change_file_ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dfsp-spirit","download_url":"https://codeload.github.com/dfsp-spirit/tmp_change_file_ext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfsp-spirit%2Ftmp_change_file_ext/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265080256,"owners_count":23708121,"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":["bash","infrastructure","shell","tools"],"created_at":"2024-10-31T18:11:10.760Z","updated_at":"2026-05-17T18:04:54.893Z","avatar_url":"https://github.com/dfsp-spirit.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# temporarily-change-file-extensions\nBash script to temporarily rename files with specific file extensions, and revert to the original ones later.\n\n\n## Description ##\n\nThis is a bash script which allows you to change the file extension of all files with a specific file extension\nin a certain directory (including sub directories). And, more importantly, it allows you to restore the \nchanged files (and only these -- even if other files with the temporal extension already existed before you\nstarted) to their original file extensions later.\n\n## Motivation ##\n\nThis is a hack to allow you to run tools which require a certain file extension to run on your files.\n\n(I used it to use a javascript tool which would only accept .js files, but my source files were React.js files using the .jsx file extension. I also had test files in there which had the .js file extension already, and I wanted to keep that extension.)\n\n\n## Installation ##\n\nDownload or clone the script from github, make sure it is executable.\n\n    git clone https://github.com/dfsp-spirit/tmp_change_file_ext.git\n    cd tmp_change_file_ext\n    chmod +x ./tmp_change_file_ext.sh\n\n\n## Usage ##\n\nMake a backup of the directory you want to change (or make a new, clean branch to work in if using version control like git).\n\nThen run the script like this to get help:\n\n    ./tmp_change_file_ext.sh -h\n    [TMPEXTCH] USAGE: ./tmp_change_file_ext.sh -c \u003coptions\u003e [-f]\n    [TMPEXTCH] USAGE: ./tmp_change_file_ext.sh -r \u003coptions\u003e\n    [TMPEXTCH] USAGE: ./tmp_change_file_ext.sh -h\n    [TMPEXTCH] valid options are:\n    [TMPEXTCH]   -c         : change mode (rename files according to settings and create mapping file)\n    [TMPEXTCH]   -r         : restore mode (restore previsously renamed files to their original file extensions)\n    [TMPEXTCH]   -s \u003cext\u003e   : set source or original file extension to \u003cext\u003e. Defaults to 'jsx' if omitted.\n    [TMPEXTCH]   -t \u003cext\u003e   : set temporary file extension to \u003cext\u003e. Defaults to 'js' if omitted.\n    [TMPEXTCH]   -d \u003cdir\u003e   : set directory to work on to \u003cdir\u003e. Defaults to '.' if omitted.\n    [TMPEXTCH]   -f         : force action, even if this means overwriting an existing file extension mapping file (only applies to change mode).\n    [TMPEXTCH]   -m \u003cfile\u003e  : set mapping file location to \u003cfile\u003e. Defaults to '~/.renamed_files.lst' if omitted.\n    [TMPEXTCH]   -h         : show this help and exit\n    [TMPEXTCH] EXAMPLES:\n    [TMPEXTCH] * Rename all jsx files to js in ~/my_project/:\n    [TMPEXTCH]    ./tmp_change_file_ext.sh -c -d ~/my_project/\n    [TMPEXTCH]   Restore the file names from the last action:\n    [TMPEXTCH]    ./tmp_change_file_ext.sh -r -d ~/develop/my_project/\n    [TMPEXTCH] * Rename all txt files to lst in /tmp/doc/:\n    [TMPEXTCH]    ./tmp_change_file_ext.sh -c -s txt -t lst -d /tmp/doc/\n    [TMPEXTCH]   Restore the file names from the last action:\n    [TMPEXTCH]    ./tmp_change_file_ext.sh -r -s txt -t lst -d /tmp/doc/\n\nThis will print the usage info, which currently looks like this:\n\n\n\n### Limitations ###\n\nThis version of the script only considers the file extension as the part behind the last dot. Thus, it cannot be used to rename .tar.gz files to .tgz.\n\n## Usage example / Test it before using it ##\n\nYou can try it in the test/ directory, which contains a number of js and jsx files in sub directories. \n\nLet's first inspect the directory structure and files we have in here, e.g., by running the `tree` command if you have it installed:\n\n    cd \u003crepo\u003e/test/\n    tree\n    \nNow let's rename the files:\n    \n    ../tmp_change_file_ext.sh -c\n\nNote that renaming from jsx to js is the default, so we do not need the -s and -t options in this special case. (It would not hurt to add them of course, and\nexpress that command as `../tmp_change_file_ext.sh -c -s jsx -t js -d .` instead.)\n    \nNow inspect the directory structure again.\n\n    tree\n    \nYou could make changes or run a tool now. But we will simply restore the original file extensions now:\n\n    ../tmp_change_file_ext.sh -r\n\nAnd inspect the directory structure again.\n\n    tree\n\n\n    \n## License ##\n\nThis is released under the WTFPL, see http://www.wtfpl.net/ or the LICENSE file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfsp-spirit%2Ftmp_change_file_ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdfsp-spirit%2Ftmp_change_file_ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfsp-spirit%2Ftmp_change_file_ext/lists"}