I often have to mark (or unmark) a number of files as read-only. And more often than not the files are not only in the top-level directory but in sub-directories, and sometimes below that. Right now I select the files in the top-level directory and tick (or untick) the read-only box in the info panel. Is there any way to select the top-level directory and have the files in it, and below it, all have the read-only attribute changed?
Thanks.
Read-only For Sub-directories
-
phred
- Posts: 638
- Joined: 26 Dec 2021 02:10
- Location: XY 64bit on Win10 at 100% from Boston USA
-
jupe
- Posts: 3446
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Re: Read-only For Sub-directories
You can do this through the system dialog pretty easily, so right click the folder go to Properties then select RO in that dialog, would that method be short enough for you, or are you after a one click scripted solution?
-
phred
- Posts: 638
- Joined: 26 Dec 2021 02:10
- Location: XY 64bit on Win10 at 100% from Boston USA
Re: Read-only For Sub-directories
Thanks jupe, that method would be enough for me, but that's what I've been trying and it doesn't hit the sub-directories. Right now I have this directory structure:
Top-level
Level 2
Sub-level 2
file 1
file 2
file 3
Level 3
Sub-level 3
file 1
file 2
file 3
I select the top-level directory and am at the properties tab of the info panel. I untick 'read-only, click the green tick mark and nothing. The status bar show "folder sized done in 9.3 ms (scanned 6 folders with 98 files." But all the files are still R/O.
-
jupe
- Posts: 3446
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Re: Read-only For Sub-directories
Not the Info Panel Properties tab, the Windows OS Properties dialog, you can also get to it from Alt+DblClick on the folder in the list pane besides my previous instructions of rightclick., also make sure that it is a tick in the RO checkbox, not a black square either, anyway here is a scripted version if wanted:
attrstamp("r", 3, quicksearch("/f", <curitem>));-
phred
- Posts: 638
- Joined: 26 Dec 2021 02:10
- Location: XY 64bit on Win10 at 100% from Boston USA
Re: Read-only For Sub-directories
AHHH! I remember that popup dialog. Yes, doing it via the Windows popup does what I'm looking for.
Thanks for the script. Not having used many scripts since adopting XY, I tested this on files that were -not- R/O and it marked them R/O. What needs to change if I want the script to -remove- the R/O attribute? I tried changing the r to -r but that didn't do the trick.
Thanks for the script. Not having used many scripts since adopting XY, I tested this on files that were -not- R/O and it marked them R/O. What needs to change if I want the script to -remove- the R/O attribute? I tried changing the r to -r but that didn't do the trick.
-
jupe
- Posts: 3446
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Re: Read-only For Sub-directories
I updated the script in the post, it should toggle the attr now, but it was meant for a single folder selected, if you want it to work on a selection of files too, it will need further modifying.
-
phred
- Posts: 638
- Joined: 26 Dec 2021 02:10
- Location: XY 64bit on Win10 at 100% from Boston USA
Re: Read-only For Sub-directories
I must be doing something wrong. I deleted the first .xys file and created a new one with the modified code. I navigate to load script and then run script. But the window that pops up isn't showing the new, modified script. I have exited and relaunched XY with no change.
You do not have the required permissions to view the files attached to this post.
-
jupe
- Posts: 3446
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Re: Read-only For Sub-directories
That looks like the Scripting | Run Script dialog, you need to manually add the 3 if you want it to work in there or re-paste, or use Scripting | Load Script File or similar if you really want to load it from a xys file.
There isn't really a need to have it in a xys file though, you can just add the code directly into a CTB/UDC/Catalog etc.
There isn't really a need to have it in a xys file though, you can just add the code directly into a CTB/UDC/Catalog etc.
-
phred
- Posts: 638
- Joined: 26 Dec 2021 02:10
- Location: XY 64bit on Win10 at 100% from Boston USA
Re: Read-only For Sub-directories
That's my inept scripting knowledge. It just shows me I really should find the time to start experimenting with it.
Running the modified version from the address bar works. It also works when I manually add the 3 to the run script dialog. Having it toggle is a nice touch rather than one to enable and one to disable. And to make it a one-click function, I put it on a custom toolbar button.
A tip of the ol' phred hat to you, jupe. Thanks.
Running the modified version from the address bar works. It also works when I manually add the 3 to the run script dialog. Having it toggle is a nice touch rather than one to enable and one to disable. And to make it a one-click function, I put it on a custom toolbar button.
A tip of the ol' phred hat to you, jupe. Thanks.
XYplorer Beta Club