youtuber

File and folder hiding problem

16 posts in this topic




#3 ·  Posted

How to hide files and folders with FileGetAttrib and make them visible again?

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

Hi.

First you have to make all hidden files visible. This snippet I use to toggle between showing/not showing hidden files:

Local $siAktuell = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden")
Switch $siAktuell
    Case 1  ;Hidden Files are visible
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "REG_DWORD", "00000002"); hide them
    Case 2  ;Hidden Files are unvisible
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "REG_DWORD", "00000001"); show them all
EndSwitch
Exit

Regards, Conrad


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE   H:\...\AutoIt3   H:\...\AutoIt3\Include   H: = Network Drive

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

#5 ·  Posted

@Simpel Ok i understood but this is not what i want

I guess my codes are problematic

 

Please help me with this issue

If StringInStr(FileGetAttrib($aFileFolder),"H") Then

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

Hi.

Describe the problem. What did you do? What happens, what happens not? How is your workflow? What are the (error) messages in the console?

Conrad


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE   H:\...\AutoIt3   H:\...\AutoIt3\Include   H: = Network Drive

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

#8 ·  Posted

Hi.

I get @@ Debug(3) : $test = 3. But only if I chose a hidden file. A not hidden file has no attribute "H".

Conrad


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE   H:\...\AutoIt3   H:\...\AutoIt3\Include   H: = Network Drive

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Is this code wrong?

ElseIf StringInStr(FileGetAttrib($aFileFolder),"AH") Then

If StringInStr(FileGetAttrib($aFileFolder),"-H") Then
    FileSetAttrib($aFileFolder, "+H", 1)
ElseIf StringInStr(FileGetAttrib($aFileFolder),"AH") Then
    FileSetAttrib($aFileFolder, "-H", 1)
EndIf

Or this

If StringInStr(FileGetAttrib($aFileFolder),"-H") Then
    FileSetAttrib($aFileFolder, "+H", 1)
ElseIf StringInStr(FileGetAttrib($aFileFolder),"AH") Then
    FileSetAttrib($aFileFolder, "-H", 1)
ElseIf StringInStr(FileGetAttrib($aFileFolder),"A") Then
    FileSetAttrib($aFileFolder, "+H", 1)
EndIf

 

Edited by youtuber

Share this post


Link to post
Share on other sites

#10 ·  Posted

You have to change +H and -H:

$aFileFolder = FileOpenDialog("Test", @ScriptDir & "\", "All (*)")

If StringInStr(FileGetAttrib($aFileFolder),"H") Then
    FileSetAttrib($aFileFolder, "-H", 1)
Else
    FileSetAttrib($aFileFolder, "+H", 1)
EndIf

If attribute is "H" then it is hidden and you want to unhide it so set new attribute to "-H". Otherwise set it hidden with "+H"

Conrad

1 person likes this

SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE   H:\...\AutoIt3   H:\...\AutoIt3\Include   H: = Network Drive

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

#11 ·  Posted

understood thanks
What parameters Attribute are used for the folder?

 

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

Click on

FileGetAttrib()

and you can read it in the helpfile.

Conrad


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE   H:\...\AutoIt3   H:\...\AutoIt3\Include   H: = Network Drive

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

#14 ·  Posted

You want to hide/unhide folders? Same as in my example above. You only have to change FileOpenDialog with FileSelectFolder - what you already did in your snippet.

Conrad


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE   H:\...\AutoIt3   H:\...\AutoIt3\Include   H: = Network Drive

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

#16 ·  Posted

Ok nearly. If you use FileSelectFolder you will always only get folders. So you don't have to check whether it has the attribute "D". What you want to know is if the folder is hidden (means attribute "H").

So change in line 2 "D" with "H" and it should work. Conrad

1 person likes this

SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE   H:\...\AutoIt3   H:\...\AutoIt3\Include   H: = Network Drive

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

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