You are not logged in.
Pages: 1
I tried to search the forum for some possible results about this very simple doubt, but I couldn't find anything so far... My apologies if I'm asking something that has already been answered before (or is just too simple for here):
- Is there any predefined function that I could use in a Pascal Script to set the file "read-only" flag on and off?
(e.g. just like "SetFileTimeModified(FileName, DateTime)" sets the File Modification Time to a desired value, I wold like to set the "Read only flag" of the file on some specific files that already attend some specifications inside the Pascal Script I wrote)
Many thanks. Any suggestion that would point me in the direction of accomplishing that simple task inside the Pascal Script will be extremely appreciated!
P.S.: I did check http://www.den4b.com/wiki/ReNamer:Pasca … :Functions first, but coldn't find anything on that specific subject either...
Last edited by auwebio (2011-09-03 10:43)
Offline
Not sure if PS can do this out of the box, or even if Denis will want to add this to a renaming app, but why not call a simple external program that can set any attribute you want?
Last edited by Andrew (2011-09-04 11:27)
Offline
Not sure if PS can do this out of the box, or even if Denis will want to add this to a renaming app, but why not call a simple external program that can set any attribute you want?
PS??
I did though about that idea - an external program to set the attribute for me - but the fact that I already separate all the exact files that need to be flagged as read-only trough the renaming process (inside the Pascal Script) and the fact that I already manipulate the modified time (which is much more complicated than the simple on/off flag of the read-only attribute) made me think that there must be a way to do it more fast and efficiently inside ReNamer.
It is not as fast or elegant solution, but it should probably work by either calling something on the windows shell or a small external program to do it for me. I was just hoping that I didn't have to resort to that, since it will probably "pop up" hundreds of undesirable new windows during the process of renaming the files, just for the purpose of setting up a tiny flag...
Offline
Apparently I was wrong... (just kiddin' - I was wrong!!)
since it will probably "pop up" hundreds of undesirable new windows during the process of renaming the files
By making use of the "ExecConsoleApp" function together with the windows shell "attrib" command, it works flawlessly:
CMDLine := 'attrib +r ' + '"' + FPath + FName + FExt + '"';
ExecConsoleApp(CMDLine, MSG);
it definitely did not "pop up" any new window! (I haven't figured out why, but I'm quite happy about it)
Case closed!
Thank you Andrew for trying to help. I really apprecciate it.
Edit: it will probably work the same for all the other file attributes, e.g. archive/hidden/system... (if anybody is in need of setting those)
Last edited by auwebio (2011-09-05 02:33)
Offline
PS = PascalScript.
The reason why 100s of windows aren't created is that the console-based process is executed in the background, and its output piped into a buffer that is made available to the user via PS.
Anyway, you solved it by doing exactly what I suggested, i.e. calling a simple external program (in this case System32\attrib.exe) to do the job. Like I said, I didn't see this as something that would be really appropriate for addition to ReNamer as an internal PS function.
Offline
PS = PascalScript.
Thank you for clearing that up. I should have thought of that, but somehow I didn't...
The reason why 100s of windows aren't created is that the console-based process is executed in the background, and its output piped into a buffer that is made available to the user via PS.
very good to know.
...calling a simple external program...something that would be appropriate for addition to ReNamer as an internal PS function...
Indeed. I hadn't realized (until right now) that for those functions to be available for us they had to be coded into the program first! (duh! -for me ) I thought at first they were part of some library already available with hundreds of functions, just like a regular compiler, for instance. This is what led me to believe that the "read-only" flag setting function had to be there and just wasn't included in the available documentation.
Offline
Pages: 1