Jump to content

Best way to remove old favorites/bookmarks and add new one


Go to solution Solved by JLogan3o13,

Recommended Posts

Posted

If I were to remove favorites for a wildcard user xxx at C:usersxxxFavorites  and delete an internet shortcut?  Within this favorites folder, you can delete directories, but these are specifically internet shortcuts saved as "Google home page" for example.  So I cant use DirRemove.  

Same goes for adding a bookmark/favorite as an Internet Shortcut in the above path, instead of a folder. 

Any help is appreciated :)

  • Moderators
Posted

I would start with doing a _FileListToArray, then you can loop through and delete them if they match certain criteria:

 

#include <Array.au3>
#include <File.au3>
 
$aArray = _FileListToArray(@FavoritesDir, "*", 0, 1)
 _ArrayDisplay($aArray)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

 

I would start with doing a _FileListToArray, then you can loop through and delete them if they match certain criteria:

#include <Array.au3>
#include <File.au3>
 
$aArray = _FileListToArray(@FavoritesDir, "*", 0, 1)
 _ArrayDisplay($aArray)

Thats pretty similar to what I had at first, however I couldnt get the script to delete "Google Home page"  Internet Shortcut.  I looked for the string "Google Home page" and using FileDelete if it found that string, but for some reason couldnt get it to work with the existing script posted below. 

#RequireAdmin
#NoTrayIcon

#include <array.au3>
#include <file.au3>

Local $ShortcutList = _FileListToArray(@FavoritesDir)
If @error = 1 Then
    MsgBox(0, "", "No folders Found.")
    Exit
EndIf
If @error = 4 Then
    MsgBox(0, "", "No files found.")
    Exit
EndIf
_ArrayDisplay($ShortcutList, "$ShortcutList")
  • Moderators
  • Solution
Posted

This works just fine for me:

 

#include <File.au3>
 
$aArray = _FileListToArray(@FavoritesDir, "*", 1, 1)
 
For $element In $aArray
  If StringInStr($element, "Google Home Page") Then FileDelete($element)
Next

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...