Skip to content

Instantly share code, notes, and snippets.

@Freso
Created June 14, 2017 23:12
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 Freso/af28542fa72f2ac4a352ceadf39810ec to your computer and use it in GitHub Desktop.
Save Freso/af28542fa72f2ac4a352ceadf39810ec to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
#
# Copyright © 2017 Frederik “Freso” S. Olesen <https://freso.dk/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Simple script to compile files for packaging in Bethesda's Creation Kit.
Usage:
python3 ck-prepare-archive.py <path>
E.g., if you have all you files in "F:\\Projects\\MyAwesomeMod\\Data", then you
call ``python3 ck-prepare-archive.py F:\\Projects\\MyAwesomeMod\\Data``.
"""
import json
import ntpath
import os
import sys
filelist = []
def get_data_path(root, file, start=os.curdir):
filepath = ntpath.relpath(ntpath.join(root, file), start=start)
return ntpath.join("Data", filepath)
def main(rootdir):
for item in os.listdir(rootdir):
itempath = ntpath.join(rootdir, item)
if ntpath.isdir(itempath):
for root, dirs, files in os.walk(itempath):
for file in files:
filelist.append(get_data_path(root, file, start=rootdir))
print(json.dumps(filelist))
if __name__ == "__main__":
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment