Re: js.global.file_renameã By: Mortifis to All on Mon Aug 19 2019 12:53 pmãã > What is the proper usage of file_rename? I have a script to move and renameã > files but it doesn't seem to work :-/ã >ã > load("sbbsdefs.js");ã >ã > if (argc==0)ã > path = prompt("Copy/Rename from");ã > elseã > path = argv[0];ã >ã > if (path==undefined) exit();ã >ã > if (path.indexOf('*')<0 && path.indexOf('?')<0)ã > path += "*"; // No pattern specifiedã >ã > path1 = prompt("Copy/Rename to");ã >ã > if (path1==undefined) exit();ã >ã > dir = directory(path,GLOB_PERIOD);ã >ã > for (i in dir) {ã > if(this.bbs && bbs.sys_status&SS_ABORT) break;ã > print('Renaming '+ dir[i] + ' to ' + dir[i].toLowerCase());ã > js.global.file_copy(dir[i], path1 + backslash()+ã > dir[i].toLowerCase() + '.bak');ã > mswait(1);ã > }ã >ã > I also tried with file_rename(...)ã >ã > No errors are reported either way.ããYou have to check the return value of file_rename() to know whether it succeeded or not. If it fails (returns false), then the global errno/errno_str properties could indicate why it failed.ãã > Any ideas?ããThe proper usage of file_rename is file_rename(path/oldname, path/newname) (like it says at
http://synchro.net/docs/jsobjs.html), so without knowing the values of the arguments you're passing and the state of your file system(s), I can't guess. I suggest printing some debug output to find out what's going on.ãã digital manããThis Is Spinal Tap quote #24:ãDavid St. Hubbins: You're a haughty one, saucy Jack.ãNorco, CA WX: 84.1øF, 51.0% humidity, 8 mph NE wind, 0.00 inches rain/24hrsã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã