Subj : js.global.file_rename
To : Mortifis
From : Digital Man
Date : Mon Aug 19 2019 01:39 pm
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