Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Setting and Removing write protection in files (Read 2358 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Setting and Removing write protection in files

others and me were asking over time for an option to remove and set write protection for files loaded in foobar. this is usefull for tagging of my otherwise write protected library.
it seems not possible with the old version of foo_run by florian, but in mp3 tag it is doable.
and i dont see another way doing this within foobar.
see my last thread about it.

Re: Setting and Removing write protection in files

Reply #1
I don't understand the reason you set the write protection attribute. It's just a flag programs are free to ignore.

The foo_run component is not obsolete. It's the only one of its kind and nothing has obsoleted it. Also it absolutely can be used to set or remove the read-only attribute on all your files with a single click.

Edit:
Example configuration for marking selected files with read-only attribute:

Attribute removal uses same settings except +r is changed to -r.

Re: Setting and Removing write protection in files

Reply #2
that does not work with multiple files here. i run win7 x64. is your example really working with multiple files in different folders?

the reason is: i set all soundfiles write protected because of strange tagging behaviour of NI Traktor. since years that program is messing with files in a way i dont like.
and btw there is not only one but two foo run versions. florians is marked for foobar versions up to 0.9. this is the one you are referring to. but i could not figure out the write protection setting for multiple files. as said.
there is also http://www.foobar2000.org/components/view/foo_runcmd -> This version of the component requires foobar2000 1.0. and is different.


Re: Setting and Removing write protection in files

Reply #3
that does not work with multiple files here. i run win7 x64. is your example really working with multiple files in different folders?
Did you configure the component exactly as in my screenshot? I just ran it on my entire library and it worked on all the thousands of files and with each album in a different directory. Directory or OS version should be irrelevant for it anyway as the command is run separately for each selected track from the foobar2000's installation directory and it gets the full file path as a parameter.
There was a minor issue though. The command loop is executing in the player's main thread and the UI stops responding when things take too long. You shouldn't click anywhere on the UI or Windows will suggest killing the task as it thinks the player is stuck.

the reason is: i set all soundfiles write protected because of strange tagging behaviour of NI Traktor. since years that program is messing with files in a way i dont like.
OK, that explains your write protection use. Weird that the software doesn't allow disabling its tagging.

and btw there is not only one but two foo run versions. florians is marked for foobar versions up to 0.9. this is the one you are referring to. but i could not figure out the write protection setting for multiple files. as said.
there is also http://www.foobar2000.org/components/view/foo_runcmd -> This version of the component requires foobar2000 1.0. and is different.
We were talking about foo_run, the other one is foo_runcmd. One is for running external programs on the selected tracks, one is for running internal foobar2000 commands.

There seems to be some confusion about foobar2000 component compatibility. The compatibility has been broken only once between version 0.8.x and 0.9 when foobar2000 changed everything internally. Those old pre-0.9 components don't work on modern foobar2000 but all 0.9+ components work on foobar versions that are equal or newer than the SDK used in the component.

There was a bug in some early 0.9 versions that caused memory allocation errors on Windows Vista (and newer) so running into a component build with a bugged SDK can cause crashing. This bug was quickly fixed in 2006 so running into a component made with a bugged SDK should be extremely unlikely.

Re: Setting and Removing write protection in files

Reply #4
Quote
Did you configure the component exactly as in my screenshot?
just to be shure, this is what i set:
Code: [Select]
attrib.exe +r "%path%"
and
Code: [Select]
attrib.exe -r "%path%"
this only sets attributes for the first of the marked files in foobar here. if you click on the link of the other thread i was starting in november, there was the same problem with other code and Pollux88 said it might not be possible to do with foo_run. thats why i started this thread.

please check my code and if its exactly what you meant i am even more perplexed. i wouldnt think OS or directory matters either. if i set the code right what prevents foobar from behaving the same way as it does on your machine?


Re: Setting and Removing write protection in files

Reply #5
The setting that affects this is "Simultaneous runs". As my screenshot shows it needs to be "Unlimited".

Re: Setting and Removing write protection in files

Reply #6
 :-[  i bow deep for this revelation, its a big help, i was too busy looking at execution codes rather than looking at/understanding the whole GUI. thanx a lot and happy holydays. this toppic can be closed.

Re: Setting and Removing write protection in files

Reply #7
Code: [Select]
// ==PREPROCESSOR==
// @name "WSH panel. change file attributes"
// @author "kgena_ua"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

// press left mouse button to change

function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",12, 1);
var ww, wh;

DT_LEFT = 0x00000000;
DT_WORD_ELLIPSIS = 0x00040000;

MF_ENABLED = 0x00000000;

var color = RGB(90, 90, 90);
var fso = new ActiveXObject("Scripting.FileSystemObject");
var rw = [], r0 = [];

var count;
on_item_focus_change();

function on_paint(gr){
    var text1 = rw.length == 0 ? "" : rw.length + (rw.length > 1 ? "  files are" : "  file is") + " READ - WRITE";
    var text2 = ro.length == 0 ? "" : ro.length + (ro.length > 1 ? "  files are" : "  file is") + " READ - ONLY";

    var text3 = text1 ? text1 + "\n" + text2 : text2;
   
    gr.GdiDrawText( text3, font, color, 10, 10, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}

function get_file_attributes() {
    count = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count;
    file_attributes = 0;

    rw = [];
    ro = [];
   
    for (var i = 0; i < count; i++) {
        item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);
        file_path = fb.Titleformat("%path%").EvalWithMetadb(item);
        try {
            file = fso.GetFile(file_path);
            file_attributes = parseInt(file.Attributes);

            switch (file_attributes) {
            case 32:
                rw.push(i);
                break;
            case 33:
                ro.push(i);
                break;
            }
        } catch(e) {};
    }

    window.Repaint();
}

function change_attributes(k) {
    for (var i = 0; i < count; i++) {
        item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);
        file_path = fb.Titleformat("%path%").EvalWithMetadb(item);
        try {
            file = fso.GetFile(file_path);
            file.Attributes = k;
        } catch(e) {};
    }
   
    get_file_attributes();   
}

function on_selection_changed(metadb) {
    on_item_focus_change(); 
}

function on_item_focus_change() {
    window.Repaint();
    count = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count;
    get_file_attributes();
}

function on_mouse_lbtn_up (x, y){     
    var _menu = window.CreatePopupMenu();

    _menu.AppendMenuItem(MF_ENABLED, 10, "read write");
    _menu.AppendMenuItem(MF_ENABLED, 20, "read only");

    ret = _menu.TrackPopupMenu(x,y);
    if (ret == 0) return;

    switch (ret) {
    case 10:
        change_attributes(32);
        break;
    case 20:
        change_attributes(33);
        break;
    }
    _menu.Dispose();
}

function on_size(){
    ww = window.Width;  
    wh = window.Height;
}

UR5EQF. Ukraine

Re: Setting and Removing write protection in files

Reply #8
thanx kgena_ua. i understand the code is for WSH panel (foo uie wsh panel). but thats about it.  ;) i will get back to your component if there is time for some more modding. i am not that much into scripting and stuff.