js.global.file_copy(dir[i], path1 + backslash()+ dir[i].toLowerCase() + '.bak');
js.global.file_copy(dir[i], path1 + backslash()+ dir[i].toLowerCase() + '.bak');
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.
Any ideas?
This might achieve what you're looking for.
Many of these file_* methods return boolean to indicate success/failure, so there may not be an error, but the return value should be false if the operation failed.
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
Sysop: | Chris Crash |
---|---|
Location: | Huntington Beach, CA. |
Users: | 578 |
Nodes: | 8 (0 / 8) |
Uptime: | 28:37:32 |
Calls: | 10,736 |
Calls today: | 1 |
Files: | 5 |
Messages: | 443,180 |
Posted today: | 1 |