| 赞 | 3 |
| VIP | |
| 好人卡 | |
| 积分 | 44 |
| 经验 | |
| 最后登录 | 2023-10-12 |
| 在线时间 | 552 小时 |
- 梦石
- 0
- 星屑
- 4399
- 在线时间
- 552 小时
- 注册时间
- 2017-12-2
- 回帖
- 41
|
发表于 2018-4-6 13:06:41
|
显示全部楼层
本帖最后由 Mehmet 于 2018-4-6 13:08 编辑
如果只是NW.js游戏平台可以参考下我这个.
- //=============================================================================
- // Mehmet Plugins - file Rename
- // Mehmet_fileRename.js
- //=============================================================================
- /*:
- * @plugindesc 基于NW.js游戏平台游戏目录下的文件重命名.
- * @author Mehmet
- * @version 1.0
- *
- * @help
- * Plugins Command:
- * 1.文件移动
- * mehmetFileRename /img/faces/Actor3.png /img/Actor3.png
- * 2.文件重命名
- * mehmetFileRename /img/faces/Actor3.png /img/faces/Actor4.png
- * 3.文件夹(即有第三个实参)
- * mehmetFileRename /img/Test /img/Test1 true
- */
- (function() {
- var Mehmet = Mehmet || {};
- Mehmet.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- Mehmet.Game_Interpreter_pluginCommand.call(this, command, args);
- if (command.toUpperCase() === 'MEHMETFILERENAME') {
- if (Utils.isNwjs() && args[0] && args[1]) {
- if (args[2]) {
- Mehmet.fileRenamefunction(args[0], args[1], true);
- } else {
- Mehmet.fileRenamefunction(args[0], args[1]);
- }
- }
- }
- };
- Mehmet.fileRenamefunction = function(oldPath, newPath) {
- var data = null;
- if (arguments[2]) {
- var fs = require('fs');
- var oldfilePath = this.localFileDirectoryPath(oldPath);
- var newfilePath = this.localFileDirectoryPath(newPath);
- } else {
- var oldfilePath = this.localFileDirectoryPath(oldPath);
- var newfilePath = this.localFileDirectoryPath(newPath);
- var fs = require('fs');
- }
- if (!fs.existsSync(oldfilePath)) {
- return console.log("%c File not found:" + oldfilePath,"color:red;background-color:rgba(58,58,58,1)");
- }
- fs.rename(oldfilePath, newfilePath, function(err) {
- if (err) {
- console.log("%c" + err,"color:yellow;background-color:rgba(58,58,58,1)");
- }
- });
- };
- Mehmet.localFileDirectoryPath = function(filePath) {
- var path = require('path');
- var filePath = filePath || '';
- var base = path.dirname(process.mainModule.filename);
- return path.join(base, filePath);
- };
- })();
复制代码 |
|