Delete the currently used Wallpaper

Source: Internet
Author: User

In win7, the automatic wallpaper replacement function is integrated. In other words, one day I downloaded a wallpaper package from verycd, and more than 1000 of them were game wallpapers, which were directly set to automatic replacement. Many beautiful wallpapers, but some do not like them. Are they deleted one by one, OMG. Or delete it when win7 switches to a wallpaper that you don't like. There are more than 1000 million users and they are looking for dead ones. Start the thief and write a script to directly Delete the currently used wallpaper.

 

Script File (deletewallpaper. JS)

 

// Settings

// User name, user name for logon to the current system

VaR

Username

=

"Wilford"

;
// Folder containing Wallpaper

VaR

Folders

=

New

Array

();
Folders

.

Push

("F: // wide screen Wallpaper"

);

VaR

FSO

=

New

Activexobject

("Scripting. FileSystemObject"

);
VaR

F1

=

FSO

.

GetFile

("D: // users //"

+

Username

+

"// Appdata // roaming // Microsoft // windows // themes // transcodedwallpaper.jpg"

);
VaR

Filedelnum

=

0

;
VaR

Filedel

=

""

;
For

(I

=

0

; I

<

Folders

.

Length

; I

++

)
{

VaR

Folder

=

FSO

.

Getfolder

(Folders

[

I

]);

VaR

ITER

=

New

Enumerator

(Folder

.

Files

);

For

(;!

ITER

.

Atend

(); ITER

.

Movenext

())

{

VaR

File

=

ITER

.

Item

();

If

(F1

.

Size

=

File

.

Size

)

{

Filedelnum

++;

Filedel

+ =

File

.

Path

+

"/R/N"

;

File

.

Delete

();

}

}

}

VaR

DT

=

New

Date

();
VaR

Log

=

"-----"

+

DT

.

Tolocalestring

() +

"Deleting files"

+

Filedelnum

+

"Items"

+

"-----/R/N"

;
Log

+ =

Filedel

;
Log

+ =

"/R/N"

;
// Record logs to files

Logfile

=

FSO

.

Opentextfile

("Deletewallpaper. log"

,

8

,

True

);
Logfile

.

Write

(Log

);
Logfile

.

Close

();
Wscript

.

Echo

(Log

);

You can create a shortcut, put it in the Start menu, and set the shortcut key.

There are two disadvantages:

1. This method uses the file size to determine whether it is the same file. Although the two images have the same file size, the probability is not high, but this is not a reliable method. Be cautious when considering MD5 or byte comparison.

2. This method is only valid for JPG files. other formats, such as PNG, will be converted to JPG after Windows copies, so the file size is different. To solve this problem, we can only compare it from the image level. This is a relatively advanced technology that I have not studied.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.