Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Hidden file attribute in Win32

by marinersk (Priest)
on Jul 09, 2016 at 04:45 UTC ( #1167494=note: print w/replies, xml ) Need Help??


in reply to Hidden file attribute in Win32

Just to expand a bit on the answers given:

#!/usr/bin/perl use strict; use Win32::File; my $hidfnm = 'hideme.txt'; my $getatr = 0; my $getret = &Win32::File::GetAttributes($hidfnm, $getatr); if ($getret) { if ($getatr & HIDDEN) { print "File is hidden. Unhiding\n"; } else { print "File is not hidden. Hiding\n"; } # Toggle the HIDDEN flag my $setatr = ($getatr ^ HIDDEN); my $setret = &Win32::File::SetAttributes($hidfnm, $setatr); } __END__

Results:

D:\PerlMonks>hide1 D:\PerlMonks>echo>hideme.txt This is a test. D:\PerlMonks>dir Volume in drive S is SteveData Volume Serial Number is 78B4-33A0 Directory of D:\PerlMonks 07/09/2016 12:38 AM <DIR> . 07/09/2016 12:38 AM <DIR> .. 07/09/2016 12:38 AM 88 hide1.bat 07/09/2016 12:41 AM 448 hide1.pl 07/09/2016 12:41 AM 17 hideme.txt 3 File(s) 553 bytes 2 Dir(s) 29,695,066,112 bytes free D:\PerlMonks>perl hide1.pl File is not hidden. Hiding D:\PerlMonks>dir Volume in drive S is SteveData Volume Serial Number is 78B4-33A0 Directory of D:\PerlMonks 07/09/2016 12:38 AM <DIR> . 07/09/2016 12:38 AM <DIR> .. 07/09/2016 12:38 AM 88 hide1.bat 07/09/2016 12:41 AM 448 hide1.pl 2 File(s) 536 bytes 2 Dir(s) 29,695,066,112 bytes free D:\PerlMonks>perl hide1.pl File is hidden. Unhiding D:\PerlMonks>dir Volume in drive S is SteveData Volume Serial Number is 78B4-33A0 Directory of D:\PerlMonks 07/09/2016 12:38 AM <DIR> . 07/09/2016 12:38 AM <DIR> .. 07/09/2016 12:38 AM 88 hide1.bat 07/09/2016 12:41 AM 448 hide1.pl 07/09/2016 12:41 AM 17 hideme.txt 3 File(s) 553 bytes 2 Dir(s) 29,695,066,112 bytes free D:\PerlMonks>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1167494]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2023-08-19 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?