0

I have many folders with custom icons. All the folders are present in same directory.
For eg. D:\Folder is the directory which contains folder1, folder2, ..... etc.
And each folder contain their respective icon and desktop.ini files

The contents of current desktop.ini file are as follows:

[.ShellClassInfo]
ConfirmFileOp=0
NoSharing=1
IconFile=folder1.ico
IconIndex=0
InfoTip=folder1

I want to remove NoSharing=1 from each folder's desktop.ini file.

After Removal the ini file should look like :

[.ShellClassInfo]
ConfirmFileOp=0
IconFile=folder1.ico
IconIndex=0
InfoTip=folder1

The ini file is hidden and has attributes : system, hidden and archive.
Thanks for any help you may be able to provide.

Sam1803
  • 3
  • 1
  • 4

2 Answers2

0

Use sed to print every line except the unwanted line, on all the filenames, (MS Windows style pathnames), with in-place editing and backup files:

sed --in-place=.bak --quiet '/^NoSharing=1$/!p' D:\Folder\folder?\desktop.ini

(Remove the =.bak if backups aren't needed.)

agc
  • 7,973
  • 2
  • 29
  • 50
  • Sorry, but the **folders** name are not exactly folder1,2,3 etc, they are different. I used it for a general description. It would be very helpful if you could provide a way to access all the folder names. Thanks for your answer. – Sam1803 Oct 13 '17 at 08:04
  • @Sam1803, Re "*exactly folder1,2,3 etc*": please specify if `D:\Folder\` contains *any* subfolders containing `desktop.ini` folders that should *not* be changed. – agc Oct 13 '17 at 12:22
  • **D:\Folder** is the directory which contains many **_folders_** and these **_folders_** have _desktop.ini_ files. – Sam1803 Oct 14 '17 at 07:54
0

Just 1 command: Recursively(-r) replace/remove NoSharing=1 line in each desktop.ini files in D:\Folder

msr -r -p D:\Folder -f "^desktop.ini$" -S -t "(\s+)NoSharing=1\s*" -o "$1" -R

  • If you want to preview colorful replacing result, remove -R
  • If you want to backup changed files, add -K like -R -K or -RK
  • You can also filter by file name, directory name, size range, last write time range, etc., just run the exe to show built-in usages and docs, or see git docs like README.md

msr.exe/msr.gcc*/msr.cygwin is a single exe tool (about 1.6MB, no dependencies, with cross platform versions on Windows and Linux) to find and replace files or pipe text recursively and support backup: in my open project https://github.com/qualiu/msr tools directory.

Replace files

Quanmao
  • 92
  • 5
  • Since I am completely new to this. Can you tell me how to use this. – Sam1803 Oct 13 '17 at 08:16
  • You're on Windows, right? so, download the [**msr.exe**](https://github.com/qualiu/msr/raw/master/tools/msr.exe) (use `msr-Win32.exe` if your Windows is 32-bit). To use it anywhere: **Method-1**: Save it into a directory like `d:\tools` and add `d:\tools` to your computer environment variable `PATH`. **Method-2**: Copy `msr.exe` to `C:\windows\system32`. – Quanmao Oct 13 '17 at 13:29
  • Just run the exe you'll see the colorful usages and examples. Or else you can see online built-in docs like [**msr on Windows**](https://qualiu.github.io/msr/usage-by-running/msr-Windows.html) and [**readme.txt**](https://github.com/qualiu/msr/blob/master/tools/readme.txt), or [**Vivid examples**](https://qualiu.github.io/msr/demo/windows-test.html). In fact, these're all from [**README.md**](https://github.com/qualiu/msr/blob/master/README.md) – Quanmao Oct 13 '17 at 13:35