Skip to content

Instantly share code, notes, and snippets.

@kyranet
Created June 5, 2018 20:36
Show Gist options
  • Save kyranet/4fe73b367299870d88bac1b62cb04db5 to your computer and use it in GitHub Desktop.
Save kyranet/4fe73b367299870d88bac1b62cb04db5 to your computer and use it in GitHub Desktop.
Scripts to rename the schema files for SGv2.2.0 (PR https://github.com/dirigeants/klasa/pull/320). Use wisely, this is a one-time run.
:: Batch script (Windows, cmd.exe)
:: You must download this file and run it in your cmd.exe, unlike the other two
:: scripts, this does not work in the command line.
@echo off
:: Capture all files that match _Schema.json and call the next function
for /f "delims=" %%a in ('dir /a:-d /o:n /b *_Schema.json') do call :next "%%a"
pause
:: Next method, this renames the given files to the new name (_Schema -> .schema)
:next
set "newname=%~nx1"
set "newname=%newname:_S=.s%"
ren %1 "%newname%
# PowerShell script (Windows only)
# You can run this in your command line, skip the first step if
# you are already in the bwd folder.
# Access the bwd folder checking if there's a src folder,
# else access to bwd.
try { cd src/bwd } catch { cd bwd }
# Rename all files _Schema -> .schema
Get-ChildItem *_Schema.json | Rename-Item -NewName { $_.Name -replace '_Schema.json', '.schema.json' }
# Bash script (Linux, OS X?)
# You can run this in your command line, skip the first step if
# you are already in the bwd folder.
# Access the bwd folder checking if there's a src folder,
# else access to bwd.
if [ -d "src" ]; then
cd src/bwd
else
cd bwd
fi
# Rename all files _Schema -> .schema
for i in *_Schema.json; do mv $i ${i/_Schema.json/.schema.json}; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment