0

yesterday i merged two drive (D: empty and E: my data) with the EASEUS partition master in WinPE. but it failed and then i realized that 70% of my data was moved to a folder (D:\Local Disk E_72420221840) and 30% still remain in E. then copied all the data to a new disk and deleted partitions and created a new partition with a cluster size of 64KB, then restored my previously copied data to the new partition, then noticed that all my custom icons for the folders are gone. after some searching i found problem. The read-only attribute is set to all folders by default, and its necessary to display the custom icon specified in desktop.ini. but none of my folders have the read-only flag, so i tested below code

attrib +R "foldername"

and it worked (custom icon appeared again) but i have 600GB of data with lots of folders, so is there a way to easily reset all folder attributes to default Read-only? Also tried below

FOR /f %a IN ('DIR /A/D/B') DO ATTRIB +R "%a"

but it changes files attributes too (i dont want my entire files to be read only) and doesnt change for subfolders. i think i need a for loop script to check %%a is folder or file and also search for all subfolders. a few days ago i created a script for a task that can check if 1% is a folder or a file, I used this template:

if exist %1\ (echo %%1 is Folder) else if exist %1 (echo %%1 is File) else (exit)

idk if its good for my case or not, because i havent tested it much yet.

Update: as @Señor CMasMas said i was wrong. the Read-only is default attribute only for folders with custom icon. so i dont want to mess with all folder, just folders that contain desktop.ini.

1
  • Update: SenorCMasMas is often wrong but does the best they can. Answer updated, comment deleted. Jul 26, 2022 at 22:58

1 Answer 1

0

Here is the answer that I believe that you are looking for.

Try this:

for /r %d in (.) do if exist "%d\desktop.ini" pushd "%d" && ATTRIB +R . && popd

If you are putting this in a batch file, you will need to double the "%" signs.

This could have worked without the pushd and popd but I leave these here so if someone else might be working with a command that doesn't take a path.. they can substitute this to make it work.

3
  • Yes I agree with you it's not the default but it is the default attribute for folders with a custom icon. You can test it yourself, create a folder, then check its attribute, then change its icon, and then check again. So I need to change my question a bit. I need a script to find all folders containing desktop.in (ie this folder had the icon before the disaster) and set the read-only flag for that folder only.
    – amymor
    Jul 26, 2022 at 22:41
  • One more edit. Cleaned up the pushd stack. Jul 26, 2022 at 22:55
  • Thank you. Worked :)
    – amymor
    Jul 26, 2022 at 22:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .