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>
|
|---|